[llvm-commits] [llvm-gcc-4.0] r41057 - in /llvm-gcc-4.0/trunk/gcc: llvm-convert.cpp llvm-types.cpp
Lauro Ramos Venancio
lauro.venancio at gmail.com
Mon Aug 13 16:14:29 PDT 2007
Author: laurov
Date: Mon Aug 13 18:14:28 2007
New Revision: 41057
URL: http://llvm.org/viewvc/llvm-project?rev=41057&view=rev
Log:
- Handle the load/store alignment of bitfields.
- Fix a bug in TypeConverter::ConvertRECORD.
It fixes the consumer-typeset test on ARM.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=41057&r1=41056&r2=41057&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Mon Aug 13 18:14:28 2007
@@ -2478,9 +2478,9 @@
LValue LV = EmitLV(exp);
bool isVolatile = TREE_THIS_VOLATILE(exp);
const Type *Ty = ConvertType(TREE_TYPE(exp));
+ unsigned Alignment = expr_align(exp) / 8;
if (!LV.isBitfield()) {
- unsigned Alignment = expr_align(exp) / 8;
if (!DestLoc) {
// Scalar value: emit a load.
Value *Ptr = CastToType(Instruction::BitCast, LV.Ptr,
@@ -2495,7 +2495,10 @@
}
} else {
// This is a bitfield reference.
- Value *Val = Builder.CreateLoad(LV.Ptr, isVolatile, "tmp");
+ LoadInst *LI = Builder.CreateLoad(LV.Ptr, isVolatile, "tmp");
+ LI->setAlignment(Alignment);
+
+ Value *Val = LI;
unsigned ValSizeInBits = Val->getType()->getPrimitiveSizeInBits();
assert(Val->getType()->isInteger() && "Invalid bitfield lvalue!");
@@ -2968,7 +2971,9 @@
// Last case, this is a store to a bitfield, so we have to emit a
// read/modify/write sequence.
- Value *OldVal = Builder.CreateLoad(LV.Ptr, isVolatile, "tmp");
+ LoadInst *LI = Builder.CreateLoad(LV.Ptr, isVolatile, "tmp");
+ LI->setAlignment(Alignment);
+ Value *OldVal = LI;
// If the target is big-endian, invert the bit in the word.
unsigned ValSizeInBits = TD.getTypeSize(OldVal->getType())*8;
@@ -2997,7 +3002,8 @@
// Finally, merge the two together and store it.
Value *Val = Builder.CreateOr(OldVal, RHS, "tmp");
- Builder.CreateStore(Val, LV.Ptr, isVolatile);
+ StoreInst *SI = Builder.CreateStore(Val, LV.Ptr, isVolatile);
+ SI->setAlignment(Alignment);
return RetVal;
}
Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=41057&r1=41056&r2=41057&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Mon Aug 13 18:14:28 2007
@@ -1700,6 +1700,10 @@
unsigned DeclBitAlignment = Info->getTypeAlignment(DeclFieldTy)*8;
FieldOffsetInBits &= ~(DeclBitAlignment-1ULL);
+ // When we fix the field alignment, we must restart the FieldNo search
+ // because the FieldOffsetInBits can be lower than it was in the
+ // previous iteration.
+ CurFieldNo = 0;
}
// Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do
More information about the llvm-commits
mailing list