diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-10-23 02:04:01 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-10-23 02:04:01 +0000 |
commit | e2a9e90c88edb1d7466af50003b505cc1fe14b4b (patch) | |
tree | e5eb0cd9e6c89e75c98e55dcc5ef235d3009ead0 | |
parent | 4a792072ceea00696c9bbce3de74c348cce608b9 (diff) | |
download | bcm5719-llvm-e2a9e90c88edb1d7466af50003b505cc1fe14b4b.tar.gz bcm5719-llvm-e2a9e90c88edb1d7466af50003b505cc1fe14b4b.zip |
Don't try to use inreg with 0 sized structs. Thanks to Eli for reporting the
regression.
llvm-svn: 166461
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 4 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/regparm.cpp | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index a9e11cb9542..6a929a17ccd 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -810,6 +810,10 @@ bool X86_32ABIInfo::shouldUseInReg(QualType Ty, unsigned &FreeRegs) const { return false; unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32; + + if (SizeInRegs == 0) + return false; + if (SizeInRegs > FreeRegs) { FreeRegs = 0; return false; diff --git a/clang/test/CodeGenCXX/regparm.cpp b/clang/test/CodeGenCXX/regparm.cpp index 07e9aa046ef..2196c798bf3 100644 --- a/clang/test/CodeGenCXX/regparm.cpp +++ b/clang/test/CodeGenCXX/regparm.cpp @@ -21,7 +21,18 @@ struct S2 { }; 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); +} |