[cfe-commits] r166461 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGenCXX/regparm.cpp

Rafael Espindola rafael.espindola at gmail.com
Mon Oct 22 19:04:01 PDT 2012


Author: rafael
Date: Mon Oct 22 21:04:01 2012
New Revision: 166461

URL: http://llvm.org/viewvc/llvm-project?rev=166461&view=rev
Log:
Don't try to use inreg with 0 sized structs. Thanks to Eli for reporting the
regression.

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGenCXX/regparm.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=166461&r1=166460&r2=166461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Oct 22 21:04:01 2012
@@ -810,6 +810,10 @@
     return false;
 
   unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
+
+  if (SizeInRegs == 0)
+    return false;
+
   if (SizeInRegs > FreeRegs) {
     FreeRegs = 0;
     return false;

Modified: cfe/trunk/test/CodeGenCXX/regparm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/regparm.cpp?rev=166461&r1=166460&r2=166461&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/regparm.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/regparm.cpp Mon Oct 22 21:04:01 2012
@@ -21,7 +21,18 @@
 };
 
 void __attribute__((regparm(3))) foo3(struct S2 a, int b);
-// declare void @_Z4foo12S1i(i32 inreg, i32 inreg) optsize
+// CHECK: declare void @_Z4foo32S2i(i32 inreg, i32 inreg)
 void bar3(struct S2 a, int b) {
   foo3(a, b);
 }
+
+struct S3 {
+  struct {
+    struct {} b[0];
+  } a;
+};
+__attribute((regparm(2))) void foo4(S3 a, int b);
+// CHECK: declare void @_Z4foo42S3i(%struct.S3* byval align 4, i32 inreg)
+void bar3(S3 a, int b) {
+  foo4(a, b);
+}





More information about the cfe-commits mailing list