[llvm-commits] [llvm-gcc-4.2] r81254 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Bob Wilson
bob.wilson at apple.com
Tue Sep 8 13:44:06 PDT 2009
Author: bwilson
Date: Tue Sep 8 15:44:06 2009
New Revision: 81254
URL: http://llvm.org/viewvc/llvm-project?rev=81254&view=rev
Log:
Check CONSTANT_ALIGNMENT for more constants.
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=81254&r1=81253&r2=81254&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Sep 8 15:44:06 2009
@@ -985,6 +985,18 @@
return Result;
}
+/// get_constant_alignment - Return the alignment of constant EXP in bits.
+///
+static unsigned int
+get_constant_alignment (tree exp)
+{
+ unsigned int align = TYPE_ALIGN (TREE_TYPE (exp));
+#ifdef CONSTANT_ALIGNMENT
+ align = CONSTANT_ALIGNMENT (exp, align);
+#endif
+ return align;
+}
+
/// EmitLV - Convert the specified l-value tree node to LLVM code, returning
/// the address of the result.
LValue TreeToLLVM::EmitLV(tree exp) {
@@ -1029,12 +1041,12 @@
}
case COMPLEX_CST: {
Value *Ptr = TreeConstantToLLVM::EmitLV_COMPLEX_CST(exp);
- LV = LValue(Ptr, TYPE_ALIGN(TREE_TYPE(exp)) / 8);
+ LV = LValue(Ptr, get_constant_alignment(exp) / 8);
break;
}
case STRING_CST: {
Value *Ptr = TreeConstantToLLVM::EmitLV_STRING_CST(exp);
- LV = LValue(Ptr, TYPE_ALIGN(TREE_TYPE(exp)) / 8);
+ LV = LValue(Ptr, get_constant_alignment(exp) / 8);
break;
}
@@ -7991,12 +8003,7 @@
StringIsConstant,
GlobalVariable::PrivateLinkage, Init,
".str");
-
- unsigned align = TYPE_ALIGN(TREE_TYPE(exp));
-#ifdef CONSTANT_ALIGNMENT
- align = CONSTANT_ALIGNMENT (exp, align);
-#endif
- GV->setAlignment(align / 8);
+ GV->setAlignment(get_constant_alignment(exp) / 8);
if (SlotP) *SlotP = GV;
return GV;
More information about the llvm-commits
mailing list