[llvm-branch-commits] [cfe-branch] r71317 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGCall.cpp test/CodeGen/x86_32-arguments.c
Mike Stump
mrs at apple.com
Fri May 8 20:23:16 PDT 2009
Author: mrs
Date: Fri May 8 22:23:15 2009
New Revision: 71317
URL: http://llvm.org/viewvc/llvm-project?rev=71317&view=rev
Log:
Merge in 71270:
Darwin x86_32: When coercing a "single element" structure, make sure
to use a wide enough type. This might be wider than the "single
element"'s type in the presence of padding bit-fields.
- Darwin x86_32 now passes the first 1k ABI tests with bit-field
generation enabled.
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=71317&r1=71316&r2=71317&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp Fri May 8 22:23:15 2009
@@ -408,15 +408,19 @@
// Classify "single element" structs as their element type.
if (const Type *SeltTy = isSingleElementStruct(RetTy, Context)) {
if (const BuiltinType *BT = SeltTy->getAsBuiltinType()) {
- // FIXME: This is gross, it would be nice if we could just
- // pass back SeltTy and have clients deal with it. Is it worth
- // supporting coerce to both LLVM and clang Types?
if (BT->isIntegerType()) {
- uint64_t Size = Context.getTypeSize(SeltTy);
+ // We need to use the size of the structure, padding
+ // bit-fields can adjust that to be larger than the single
+ // element type.
+ uint64_t Size = Context.getTypeSize(RetTy);
return ABIArgInfo::getCoerce(llvm::IntegerType::get((unsigned) Size));
} else if (BT->getKind() == BuiltinType::Float) {
+ assert(Context.getTypeSize(RetTy) == Context.getTypeSize(SeltTy) &&
+ "Unexpect single element structure size!");
return ABIArgInfo::getCoerce(llvm::Type::FloatTy);
} else if (BT->getKind() == BuiltinType::Double) {
+ assert(Context.getTypeSize(RetTy) == Context.getTypeSize(SeltTy) &&
+ "Unexpect single element structure size!");
return ABIArgInfo::getCoerce(llvm::Type::DoubleTy);
}
} else if (SeltTy->isPointerType()) {
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=71317&r1=71316&r2=71317&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c Fri May 8 22:23:15 2009
@@ -132,4 +132,10 @@
// RUN: grep 'define float @f31()' %t &&
struct s31 { char : 0; float b; char : 0} f31(void) {}
+// RUN: grep 'define i32 @f32()' %t &&
+struct s32 { char a; unsigned : 0; } f32(void) {}
+
+// RUN: grep 'define float @f33()' %t &&
+struct s33 { float a; long long : 0; } f33(void) {}
+
// RUN: true
More information about the llvm-branch-commits
mailing list