]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/patches/patch-r262262-clang-r199037-sparc.diff
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / patches / patch-r262262-clang-r199037-sparc.diff
1 Pull in r199037 from upstream clang trunk (by Jakob Stokund Olesen):
2
3   SPARC passes non-trivial C++ objects indirectly like everybody else.
4
5 Introduced here: http://svnweb.freebsd.org/changeset/base/262262
6
7 Index: tools/clang/lib/CodeGen/TargetInfo.cpp
8 ===================================================================
9 --- tools/clang/lib/CodeGen/TargetInfo.cpp
10 +++ tools/clang/lib/CodeGen/TargetInfo.cpp
11 @@ -5349,6 +5349,11 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned
12    if (!isAggregateTypeForABI(Ty))
13      return ABIArgInfo::getDirect();
14  
15 +  // If a C++ object has either a non-trivial copy constructor or a non-trivial
16 +  // destructor, it is passed with an explicit indirect pointer / sret pointer.
17 +  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
18 +    return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory);
19 +
20    // This is a small aggregate type that should be passed in registers.
21    // Build a coercion type from the LLVM struct type.
22    llvm::StructType *StrTy = dyn_cast<llvm::StructType>(CGT.ConvertType(Ty));
23 Index: tools/clang/test/CodeGenCXX/sparcv9-abi.cpp
24 ===================================================================
25 --- tools/clang/test/CodeGenCXX/sparcv9-abi.cpp
26 +++ tools/clang/test/CodeGenCXX/sparcv9-abi.cpp
27 @@ -0,0 +1,26 @@
28 +// RUN: %clang_cc1 -triple sparcv9-unknown-unknown -emit-llvm %s -o - | FileCheck %s
29 +
30 +struct pod {
31 +  int a, b;
32 +};
33 +
34 +void f0();
35 +void f1(struct pod);
36 +
37 +struct notpod {
38 +  int a, b;
39 +  ~notpod() { f0(); }
40 +};
41 +
42 +void f2(struct notpod);
43 +
44 +// CHECK-LABEL: caller
45 +// CHECK: call void @_Z2f13pod(i64
46 +// CHECK: call void @_Z2f26notpod(%struct.notpod*
47 +void caller()
48 +{
49 +  pod p1;
50 +  notpod p2;
51 +  f1(p1);
52 +  f2(p2);
53 +}