r184603 - Check for trivial constructibility before emptiness in ARM ABI.

Tim Northover tnorthover at apple.com
Fri Jun 21 15:49:35 PDT 2013


Author: tnorthover
Date: Fri Jun 21 17:49:34 2013
New Revision: 184603

URL: http://llvm.org/viewvc/llvm-project?rev=184603&view=rev
Log:
Check for trivial constructibility before emptiness in ARM ABI.

According to the Itanium ABI (3.1.1), types with non-trivial copy constructors
passed by value should be passed indirectly, with the caller creating a
temporary.

We got this mostly correct, but forgot that empty structs can have non-trivial
constructors too and passed them incorrectly. This simply reverses the order of
the check.

Added:
    cfe/trunk/test/CodeGenCXX/empty-nontrivially-copyable.cpp
Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=184603&r1=184602&r2=184603&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Jun 21 17:49:34 2013
@@ -3340,13 +3340,13 @@ ABIArgInfo ARMABIInfo::classifyArgumentT
             ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 
+  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, CGT))
+    return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory);
+
   // Ignore empty records.
   if (isEmptyRecord(getContext(), Ty, true))
     return ABIArgInfo::getIgnore();
 
-  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, CGT))
-    return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory);
-
   if (getABIKind() == ARMABIInfo::AAPCS_VFP) {
     // Homogeneous Aggregates need to be expanded when we can fit the aggregate
     // into VFP registers.

Added: cfe/trunk/test/CodeGenCXX/empty-nontrivially-copyable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/empty-nontrivially-copyable.cpp?rev=184603&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/empty-nontrivially-copyable.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/empty-nontrivially-copyable.cpp Fri Jun 21 17:49:34 2013
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple armv7-apple-ios -x c++ -emit-llvm -o - %s | FileCheck %s
+
+// According to the Itanium ABI (3.1.1), types with non-trivial copy
+// constructors passed by value should be passed indirectly, with the caller
+// creating a temporary.
+
+struct Empty;
+
+struct Empty {
+  Empty(const Empty &e);
+  bool check();
+};
+
+bool foo(Empty e) {
+// CHECK: @_Z3foo5Empty(%struct.Empty* %e)
+// CHECK: call {{.*}} @_ZN5Empty5checkEv(%struct.Empty* %e)
+  return e.check();
+}
+
+void caller(Empty &e) {
+// CHECK: @_Z6callerR5Empty(%struct.Empty* %e)
+// CHECK: call {{.*}} @_ZN5EmptyC1ERKS_(%struct.Empty* [[NEWTMP:%.*]], %struct.Empty*
+// CHECK: call {{.*}} @_Z3foo5Empty(%struct.Empty* [[NEWTMP]])
+  foo(e);
+}





More information about the cfe-commits mailing list