[llvm-commits] [llvm-gcc-4.2] r73730 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Thu Jun 18 15:54:19 PDT 2009
Author: lattner
Date: Thu Jun 18 17:54:19 2009
New Revision: 73730
URL: http://llvm.org/viewvc/llvm-project?rev=73730&view=rev
Log:
fix rdar://6983634 - when inserting tail padding to round up an initializer to
the right size, we have to be careful when the max struct alignment will cause the
size-with-alignment to be too big. In this case, switch the struct to being packed.
This fixes rdar://6983634 and test/FrontendC/2009-06-18-StaticInitTailPadPack.c
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=73730&r1=73729&r2=73730&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jun 18 17:54:19 2009
@@ -7187,6 +7187,21 @@
if (GCCStructSize - NextFieldByteStart != 1)
FillTy = ArrayType::get(FillTy, GCCStructSize - NextFieldByteStart);
ResultElts.push_back(Constant::getNullValue(FillTy));
+ NextFieldByteStart = GCCStructSize;
+
+ // At this point, we know that our struct should have the right size.
+ // However, if the size of the struct is not a multiple of the largest
+ // element alignment, the rounding could bump up the struct more. In this
+ // case, we have to convert the struct to being packed.
+ LLVMNaturalSize =
+ TargetData::RoundUpAlignment(NextFieldByteStart, MaxLLVMFieldAlignment);
+
+ // If the alignment will make the struct too big, convert it to being
+ // packed.
+ if (LLVMNaturalSize > GCCStructSize) {
+ assert(!StructIsPacked && "LLVM Struct type overflow!");
+ ConvertToPacked();
+ }
}
}
More information about the llvm-commits
mailing list