[llvm-commits] [llvm-gcc-4.2] r63284 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 28 23:30:04 PST 2009
Author: lattner
Date: Thu Jan 29 01:30:03 2009
New Revision: 63284
URL: http://llvm.org/viewvc/llvm-project?rev=63284&view=rev
Log:
a field being packed doesn't affect its alignment as far as lvalue
computation is concerned, just its offset from the start of the struct.
A packed field or any other field with 1-byte alignment is just
MinAlign(base, offset) like anything else.
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=63284&r1=63283&r2=63284&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jan 29 01:30:03 2009
@@ -6090,7 +6090,7 @@
LValue TreeToLLVM::EmitLV_COMPONENT_REF(tree exp) {
LValue StructAddrLV = EmitLV(TREE_OPERAND(exp, 0));
tree FieldDecl = TREE_OPERAND(exp, 1);
- unsigned LVAlign = DECL_PACKED(FieldDecl) ? 1 : StructAddrLV.Alignment;
+ unsigned LVAlign = StructAddrLV.Alignment;
assert((TREE_CODE(DECL_CONTEXT(FieldDecl)) == RECORD_TYPE ||
TREE_CODE(DECL_CONTEXT(FieldDecl)) == UNION_TYPE ||
@@ -6128,6 +6128,9 @@
const StructLayout *SL = TD.getStructLayout(cast<StructType>(StructTy));
unsigned Offset = SL->getElementOffset(MemberIndex);
BitStart -= Offset * 8;
+
+ // If the base is known to be 8-byte aligned, and we're adding a 4-byte
+ // offset, the field is known to be 4-byte aligned.
LVAlign = MinAlign(LVAlign, Offset);
}
@@ -6214,6 +6217,8 @@
Offset = Builder.CreateAdd(Offset,
ConstantInt::get(Offset->getType(), ByteOffset));
BitStart -= ByteOffset*8;
+ // If the base is known to be 8-byte aligned, and we're adding a 4-byte
+ // offset, the field is known to be 4-byte aligned.
LVAlign = MinAlign(LVAlign, ByteOffset);
}
More information about the llvm-commits
mailing list