[llvm-branch-commits] [llvm-gcc-branch] r85291 - /llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Tue Oct 27 13:13:41 PDT 2009
Author: void
Date: Tue Oct 27 15:13:41 2009
New Revision: 85291
URL: http://llvm.org/viewvc/llvm-project?rev=85291&view=rev
Log:
$ svn merge -c 85284 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r85284 into '.':
U gcc/llvm-convert.cpp
Modified:
llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp?rev=85291&r1=85290&r2=85291&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp Tue Oct 27 15:13:41 2009
@@ -7789,6 +7789,23 @@
uint64_t GCCFieldOffsetInBits = getFieldOffsetInBits(Field);
NextField = TREE_CHAIN(Field);
+ uint64_t FieldSizeInBits = getInt64(DECL_SIZE(Field), true);
+ uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits();
+ ConstantInt *ValC = dyn_cast<ConstantInt>(Val);
+ if (ValC && ValC->isZero()) {
+ // G++ has various bugs handling {} initializers where it doesn't
+ // synthesize a zero node of the right type. Instead of figuring out G++,
+ // just hack around it by special casing zero and allowing it to be the
+ // wrong size.
+ if (ValueSizeInBits != FieldSizeInBits) {
+ APInt ValAsInt = ValC->getValue();
+ ValC = ConstantInt::get(Context, ValueSizeInBits < FieldSizeInBits ?
+ ValAsInt.zext(FieldSizeInBits) :
+ ValAsInt.trunc(FieldSizeInBits));
+ ValueSizeInBits = FieldSizeInBits;
+ Val = ValC;
+ }
+ }
// If this is a non-bitfield value, just slap it onto the end of the struct
// with the appropriate padding etc. If it is a bitfield, we have more
@@ -7798,20 +7815,7 @@
else {
// Bitfields can only be initialized with constants (integer constant
// expressions).
- ConstantInt *ValC = cast<ConstantInt>(Val);
- uint64_t FieldSizeInBits = getInt64(DECL_SIZE(Field), true);
- uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits();
-
- // G++ has various bugs handling {} initializers where it doesn't
- // synthesize a zero node of the right type. Instead of figuring out G++,
- // just hack around it by special casing zero and allowing it to be the
- // wrong size.
- if (ValueSizeInBits < FieldSizeInBits && ValC->isZero()) {
- APInt ValAsInt = ValC->getValue();
- ValC = ConstantInt::get(Context, ValAsInt.zext(FieldSizeInBits));
- ValueSizeInBits = FieldSizeInBits;
- }
-
+ assert(ValC);
assert(ValueSizeInBits >= FieldSizeInBits &&
"disagreement between LLVM and GCC on bitfield size");
if (ValueSizeInBits != FieldSizeInBits) {
More information about the llvm-branch-commits
mailing list