r241667 - [CodeGen] Correctly handle base classes which are passed in memory

David Majnemer david.majnemer at gmail.com
Tue Jul 7 22:14:29 PDT 2015


Author: majnemer
Date: Wed Jul  8 00:14:29 2015
New Revision: 241667

URL: http://llvm.org/viewvc/llvm-project?rev=241667&view=rev
Log:
[CodeGen] Correctly handle base classes which are passed in memory

We didn't correctly process the case where a base class is classified as
MEMORY.  This would cause us to trip over an assertion.

This fixes PR24020.

Differential Revision: http://reviews.llvm.org/D10907

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=241667&r1=241666&r2=241667&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul  8 00:14:29 2015
@@ -2073,8 +2073,10 @@ void X86_64ABIInfo::classify(QualType Ty
         classify(I.getType(), Offset, FieldLo, FieldHi, isNamedArg);
         Lo = merge(Lo, FieldLo);
         Hi = merge(Hi, FieldHi);
-        if (Lo == Memory || Hi == Memory)
-          break;
+        if (Lo == Memory || Hi == Memory) {
+          postMerge(Size, Lo, Hi);
+          return;
+        }
       }
     }
 

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp?rev=241667&r1=241666&r2=241667&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/x86_64-arguments.cpp Wed Jul  8 00:14:29 2015
@@ -196,3 +196,19 @@ namespace test9 {
     return sret;
   }
 }
+
+namespace test10 {
+#pragma pack(1)
+struct BasePacked {
+  char one;
+  short two;
+};
+#pragma pack()
+struct DerivedPacked : public BasePacked {
+  int three;
+};
+// CHECK-LABEL: define i32 @_ZN6test1020FuncForDerivedPackedENS_13DerivedPackedE({{.*}}* byval align 8
+int FuncForDerivedPacked(DerivedPacked d) {
+  return d.three;
+}
+}





More information about the cfe-commits mailing list