[llvm-commits] [llvm-gcc-4.2] r63288 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 28 23:50:02 PST 2009
Author: lattner
Date: Thu Jan 29 01:50:02 2009
New Revision: 63288
URL: http://llvm.org/viewvc/llvm-project?rev=63288&view=rev
Log:
If a FIELD_DECL says its alignment is 16 bytes, and the base pointer
is only known to be 8-byte aligned, round up to 16 bytes. I believe
that this is always safe. Duncan, I would appreciate the review.
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=63288&r1=63287&r2=63288&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:50:02 2009
@@ -1161,7 +1161,7 @@
// Constants.
case LABEL_DECL: {
Value *Ptr = TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
- return LValue(Ptr, DECL_ALIGN(exp) / 8);
+ return LValue(Ptr, DECL_ALIGN_UNIT(exp));
}
case COMPLEX_CST: {
Value *Ptr = TreeConstantToLLVM::EmitLV_COMPLEX_CST(exp);
@@ -6198,9 +6198,15 @@
LVAlign = MinAlign(LVAlign, Offset);
}
- // If the FIELD_DECL has an annotate attribute on it, emit it.
+ // If this field is at a constant offset, if the LLVM pointer really points
+ // to it, then we know that the pointer is at least as aligned as the field
+ // is required to be. Try to round up our alignment info.
+ if (BitStart == 0 && // llvm pointer points to it.
+ !isBitfield(FieldDecl) && // bitfield computation might offset pointer.
+ DECL_ALIGN_UNIT(FieldDecl))
+ LVAlign = std::max(LVAlign, unsigned(DECL_ALIGN_UNIT(FieldDecl)));
- // Handle annotate attribute on global.
+ // If the FIELD_DECL has an annotate attribute on it, emit it.
if (lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl)))
FieldPtr = EmitFieldAnnotation(FieldPtr, FieldDecl);
} else {
More information about the llvm-commits
mailing list