uint64_t DstSize = CGF.CGM.getTargetData().getTypeAllocSize(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);
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);
uint64_t DstSize = CGF.CGM.getTargetData().getTypeAllocSize(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);
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) {}
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) {}