Don't try to use inreg with 0 sized structs. Thanks to Eli for reporting the

regression.

llvm-svn: 166461
This commit is contained in:
Rafael Espindola 2012-10-23 02:04:01 +00:00
parent 4a792072ce
commit e2a9e90c88
2 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}