[llvm-commits] [llvm-gcc-4.2] r63321 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-types.cpp
Duncan Sands
baldrick at free.fr
Thu Jan 29 10:13:54 PST 2009
Author: baldrick
Date: Thu Jan 29 12:13:54 2009
New Revision: 63321
URL: http://llvm.org/viewvc/llvm-project?rev=63321&view=rev
Log:
Workaround for PR1000: changing TYPE_ALIGN to
TYPE_ALIGN_UNIT supposes that BITS_PER_UNIT
is 8. It's the inverse transform that improves
portability!
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=63321&r1=63320&r2=63321&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Jan 29 12:13:54 2009
@@ -1108,14 +1108,14 @@
}
// Set the alignment for the global if one of the following condition is met
- // 1) DECL_ALIGN_UNIT is better than the alignment as per ABI specification
+ // 1) DECL_ALIGN is better than the alignment as per ABI specification
// 2) DECL_ALIGN is set by user.
- if (DECL_ALIGN_UNIT(decl)) {
+ if (DECL_ALIGN(decl)) {
unsigned TargetAlign =
getTargetData().getABITypeAlignment(GV->getType()->getElementType());
if (DECL_USER_ALIGN(decl) ||
- TargetAlign < (unsigned)DECL_ALIGN_UNIT(decl))
- GV->setAlignment(DECL_ALIGN_UNIT(decl));
+ 8 * TargetAlign < (unsigned)DECL_ALIGN(decl))
+ GV->setAlignment(DECL_ALIGN(decl) / 8);
}
// Handle used decls
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=63321&r1=63320&r2=63321&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jan 29 12:13:54 2009
@@ -1161,15 +1161,15 @@
// Constants.
case LABEL_DECL: {
Value *Ptr = TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
- return LValue(Ptr, DECL_ALIGN_UNIT(exp));
+ return LValue(Ptr, DECL_ALIGN(exp) / 8);
}
case COMPLEX_CST: {
Value *Ptr = TreeConstantToLLVM::EmitLV_COMPLEX_CST(exp);
- return LValue(Ptr, TYPE_ALIGN_UNIT(TREE_TYPE(exp)));
+ return LValue(Ptr, TYPE_ALIGN(TREE_TYPE(exp)) / 8);
}
case STRING_CST: {
Value *Ptr = TreeConstantToLLVM::EmitLV_STRING_CST(exp);
- return LValue(Ptr, TYPE_ALIGN_UNIT(TREE_TYPE(exp)));
+ return LValue(Ptr, TYPE_ALIGN(TREE_TYPE(exp)) / 8);
}
// Type Conversion.
@@ -1700,12 +1700,12 @@
unsigned Alignment = 0; // Alignment in bytes.
// Set the alignment for the local if one of the following condition is met
- // 1) DECL_ALIGN_UNIT is better than the alignment as per ABI specification
+ // 1) DECL_ALIGN is better than the alignment as per ABI specification
// 2) DECL_ALIGN is set by user.
- if (DECL_ALIGN_UNIT(decl)) {
+ if (DECL_ALIGN(decl)) {
unsigned TargetAlign = getTargetData().getABITypeAlignment(Ty);
- if (DECL_USER_ALIGN(decl) || TargetAlign < (unsigned)DECL_ALIGN_UNIT(decl))
- Alignment = DECL_ALIGN_UNIT(decl);
+ if (DECL_USER_ALIGN(decl) || 8 * TargetAlign < (unsigned)DECL_ALIGN(decl))
+ Alignment = DECL_ALIGN(decl) / 8;
}
const char *Name; // Name of variable
@@ -5945,9 +5945,9 @@
if (Ty == Type::VoidTy) Ty = StructType::get(NULL, NULL);
const PointerType *PTy = PointerType::getUnqual(Ty);
unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1;
- if (DECL_ALIGN_UNIT(exp)) {
- if (DECL_USER_ALIGN(exp) || Alignment < (unsigned)DECL_ALIGN_UNIT(exp))
- Alignment = DECL_ALIGN_UNIT(exp);
+ if (DECL_ALIGN(exp)) {
+ if (DECL_USER_ALIGN(exp) || 8 * Alignment < (unsigned)DECL_ALIGN(exp))
+ Alignment = DECL_ALIGN(exp) / 8;
}
return LValue(BitCastToType(Decl, PTy), Alignment);
@@ -6187,8 +6187,8 @@
// 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)));
+ DECL_ALIGN(FieldDecl))
+ LVAlign = std::max(LVAlign, unsigned(DECL_ALIGN(FieldDecl)) / 8);
// If the FIELD_DECL has an annotate attribute on it, emit it.
if (lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl)))
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=63321&r1=63320&r2=63321&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Thu Jan 29 12:13:54 2009
@@ -1834,7 +1834,8 @@
// then convert to a packed struct and try again.
if (TYPE_USER_ALIGN(DECL_BIT_FIELD_TYPE(Field))) {
const Type *Ty = ConvertType(getDeclaredType(Field));
- if (TYPE_ALIGN_UNIT(DECL_BIT_FIELD_TYPE(Field)) != Info.getTypeAlignment(Ty))
+ if (TYPE_ALIGN(DECL_BIT_FIELD_TYPE(Field)) !=
+ 8 * Info.getTypeAlignment(Ty))
return false;
}
}
@@ -1864,7 +1865,7 @@
return false;
}
else if (TYPE_USER_ALIGN(TREE_TYPE(Field))
- && (unsigned)DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty)
+ && (unsigned)DECL_ALIGN(Field) != 8 * Info.getTypeAlignment(Ty)
&& !Info.isPacked()) {
// If Field has user defined alignment and it does not match Ty alignment
// then convert to a packed struct and try again.
@@ -2039,8 +2040,8 @@
ConvertingStruct = true;
StructTypeConversionInfo *Info =
- new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN_UNIT(type),
- TYPE_PACKED(type));
+ new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN(type) / 8,
+ TYPE_PACKED(type));
// Alter any fields that appear to represent base classes so their lists
// of fields bear some resemblance to reality.
@@ -2057,8 +2058,7 @@
if (retryAsPackedStruct) {
delete Info;
- Info = new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN_UNIT(type),
- true);
+ Info = new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN(type) / 8, true);
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
if (DecodeStructFields(Field, *Info) == false) {
assert(0 && "Unable to decode struct fields.");
@@ -2330,7 +2330,7 @@
}
}
- bool isPacked = EltAlign > TYPE_ALIGN_UNIT(type);
+ bool isPacked = 8 * EltAlign > TYPE_ALIGN(type);
const Type *ResultTy = StructType::get(UnionElts, isPacked);
const OpaqueType *OldTy = cast_or_null<OpaqueType>(GET_TYPE_LLVM(type));
TypeDB.setType(type, ResultTy);
More information about the llvm-commits
mailing list