[llvm-branch-commits] [cfe-branch] r71708 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGCall.cpp test/CodeGen/x86_32-arguments.c test/CodeGen/x86_64-arguments.c
Mike Stump
mrs at apple.com
Wed May 13 13:07:54 PDT 2009
Author: mrs
Date: Wed May 13 15:07:54 2009
New Revision: 71708
URL: http://llvm.org/viewvc/llvm-project?rev=71708&view=rev
Log:
Merge in 71695:
ABI handling: Fix invalid assertion, it is possible for a valid
coercion to be specified which truncates padding bits. It would be
nice to still have the assert, but we don't have any API call for the
unpadding size of a type yet.
Modified:
cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp
cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c
cfe/branches/Apple/Dib/test/CodeGen/x86_64-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=71708&r1=71707&r2=71708&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp Wed May 13 15:07:54 2009
@@ -1578,7 +1578,14 @@
uint64_t DstSize = CGF.CGM.getTargetData().getTypePaddedSize(Ty);
// If load is legal, just bitcast the src pointer.
- if (SrcSize == DstSize) {
+ if (SrcSize >= DstSize) {
+ // Generally SrcSize is never greater than DstSize, since this
+ // means we are losing bits. However, this can happen in cases
+ // where the structure has additional padding, for example due to
+ // a user specified alignment.
+ //
+ // FIXME: Assert that we aren't truncating non-padding bits when
+ // have access to that information.
llvm::Value *Casted =
CGF.Builder.CreateBitCast(SrcPtr, llvm::PointerType::getUnqual(Ty));
llvm::LoadInst *Load = CGF.Builder.CreateLoad(Casted);
@@ -1586,8 +1593,6 @@
Load->setAlignment(1);
return Load;
} else {
- assert(SrcSize < DstSize && "Coercion is losing source bits!");
-
// Otherwise do coercion through memory. This is stupid, but
// simple.
llvm::Value *Tmp = CGF.CreateTempAlloca(Ty);
@@ -1617,14 +1622,19 @@
uint64_t DstSize = CGF.CGM.getTargetData().getTypePaddedSize(DstTy);
// If store is legal, just bitcast the src pointer.
- if (SrcSize == DstSize) {
+ if (SrcSize >= DstSize) {
+ // Generally SrcSize is never greater than DstSize, since this
+ // means we are losing bits. However, this can happen in cases
+ // where the structure has additional padding, for example due to
+ // a user specified alignment.
+ //
+ // FIXME: Assert that we aren't truncating non-padding bits when
+ // have access to that information.
llvm::Value *Casted =
CGF.Builder.CreateBitCast(DstPtr, llvm::PointerType::getUnqual(SrcTy));
// FIXME: Use better alignment / avoid requiring aligned store.
CGF.Builder.CreateStore(Src, Casted)->setAlignment(1);
} else {
- assert(SrcSize > DstSize && "Coercion is missing bits!");
-
// Otherwise do coercion through memory. This is stupid, but
// simple.
llvm::Value *Tmp = CGF.CreateTempAlloca(SrcTy);
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=71708&r1=71707&r2=71708&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/x86_32-arguments.c Wed May 13 15:07:54 2009
@@ -131,7 +131,7 @@
struct s30 { char a; char b : 4; } f30(void) {}
// RUN: grep 'define float @f31()' %t &&
-struct s31 { char : 0; float b; char : 0} f31(void) {}
+struct s31 { char : 0; float b; char : 0; } f31(void) {}
// RUN: grep 'define i32 @f32()' %t &&
struct s32 { char a; unsigned : 0; } f32(void) {}
@@ -140,13 +140,13 @@
struct s33 { float a; long long : 0; } f33(void) {}
// RUN: grep 'define float @f34()' %t &&
-struct s34 { struct { int : 0 } a; float b; } f34(void) {}
+struct s34 { struct { int : 0; } a; float b; } f34(void) {}
// RUN: grep 'define i16 @f35()' %t &&
-struct s35 { struct { int : 0 } a; char b; char c; } f35(void) {}
+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) {}
+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) {}
Modified: cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c?rev=71708&r1=71707&r2=71708&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c Wed May 13 15:07:54 2009
@@ -55,4 +55,10 @@
// RUN: grep 'define void @f11(.union.anon. noalias sret .agg.result)' %t &&
union { long double a; float b; } f11() {}
+// RUN: grep 'define i64 @f12_0()' %t &&
+// RUN: grep 'define void @f12_1(i64)' %t &&
+struct s12 { int a __attribute__((aligned(16))); };
+struct s12 f12_0(void) {}
+void f12_1(struct s12 a0) {}
+
// RUN: true
More information about the llvm-branch-commits
mailing list