[llvm-branch-commits] [cfe-branch] r71497 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGCall.cpp test/CodeGen/x86_32-arguments.c
Mike Stump
mrs at apple.com
Mon May 11 16:19:00 PDT 2009
Author: mrs
Date: Mon May 11 18:19:00 2009
New Revision: 71497
URL: http://llvm.org/viewvc/llvm-project?rev=71497&view=rev
Log:
Merge in 71490:
Darwin x86-32: Multi-dimensional arrays were not handled correctly,
spotted by Eli!
Modified:
cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp
cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c
Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp?rev=71497&r1=71496&r2=71497&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp Mon May 11 18:19:00 2009
@@ -166,10 +166,9 @@
return true;
QualType FT = FD->getType();
- // Arrays of empty records count as empty.
- if (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT))
- if (isEmptyRecord(Context, AT->getElementType()))
- return true;
+ // Constant arrays of empty records count as empty, strip them off.
+ while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT))
+ FT = AT->getElementType();
return isEmptyRecord(Context, FT);
}
@@ -218,14 +217,18 @@
if (isEmptyField(Context, FD))
continue;
- // Treat single element arrays as the element
- if (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT))
- if (AT->getSize().getZExtValue() == 1)
- FT = AT->getElementType();
-
+ // If we already found an element then this isn't a single-element
+ // struct.
if (Found)
return 0;
+ // Treat single element arrays as the element.
+ while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) {
+ if (AT->getSize().getZExtValue() != 1)
+ break;
+ FT = AT->getElementType();
+ }
+
if (!CodeGenFunction::hasAggregateLLVMType(FT)) {
Found = FT.getTypePtr();
} else {
Modified: cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c?rev=71497&r1=71496&r2=71497&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c Mon May 11 18:19:00 2009
@@ -145,4 +145,10 @@
// RUN: grep 'define i16 @f35()' %t &&
struct s35 { struct { int : 0 } a; char b; char c; } f35(void) {}
+// RUN: grep 'define i16 @f36()' %t &&
+struct s36 { struct { int : 0 } a[2][10]; char b; char c; } f36(void) {}
+
+// RUN: grep 'define float @f37()' %t &&
+struct s37 { float c[1][1]; } f37(void) {}
+
// RUN: true
More information about the llvm-branch-commits
mailing list