]> granicus.if.org Git - clang/commitdiff
Revert changes to DefaultABIInfo accidentally introduced in r208733
authorReid Kleckner <reid@kleckner.net>
Mon, 18 May 2015 22:46:30 +0000 (22:46 +0000)
committerReid Kleckner <reid@kleckner.net>
Mon, 18 May 2015 22:46:30 +0000 (22:46 +0000)
Also add trivial handling of transparent unions.

PPC32, MSP430, and XCore apparently all rely on DefaultABIInfo. This
should worry you, because DefaultABIInfo is not implementing the rules
of any particular ABI.

Fixes PR23097, patch by Andy Gibbs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237630 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGenCXX/powerpc-byval.cpp [new file with mode: 0644]

index 9d2871649c832771605e9461075d53aa48f0b261..b6a53c9f45b28bae159dbbab68a9bc01b8ddfe2e 100644 (file)
@@ -406,8 +406,16 @@ llvm::Value *DefaultABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
 }
 
 ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
-  if (isAggregateTypeForABI(Ty))
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (isAggregateTypeForABI(Ty)) {
+    // Records with non-trivial destructors/copy-constructors should not be
+    // passed by value.
+    if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
+      return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory);
+
     return ABIArgInfo::getIndirect(0);
+  }
 
   // Treat an enum type as its underlying type.
   if (const EnumType *EnumTy = Ty->getAs<EnumType>())
diff --git a/test/CodeGenCXX/powerpc-byval.cpp b/test/CodeGenCXX/powerpc-byval.cpp
new file mode 100644 (file)
index 0000000..ff87618
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=powerpc-unknown-linux | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+void byval(S one, S two) {
+  one = two;
+}
+
+// CHECK: define void @_Z5byval1SS_(%struct.S* %one, %struct.S* %two)