[llvm-branch-commits] [llvm-gcc-branch] r75694 - /llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Tue Jul 14 15:54:06 PDT 2009
Author: void
Date: Tue Jul 14 17:54:06 2009
New Revision: 75694
URL: http://llvm.org/viewvc/llvm-project?rev=75694&view=rev
Log:
--- Merging r73730 into 'gcc/llvm-convert.cpp':
U gcc/llvm-convert.cpp
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/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp?rev=75694&r1=75693&r2=75694&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp Tue Jul 14 17:54:06 2009
@@ -7114,6 +7114,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-branch-commits
mailing list