Author: johannes
Date: Fri Feb 15 16:02:22 2008
New Revision: 47180
URL: http://llvm.org/viewvc/llvm-project?rev=47180view=rev
Log:
Put back fixed version of code to avoid copying
padding within structs (sometimes).
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-internal.h
llvm-gcc-4.2/trunk/gcc/llvm-types.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=47180r1=47179r2=47180view=diff
==
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Feb 15 16:02:22 2008
@@ -1229,7 +1229,8 @@
/// CopyAggregate - Recursively traverse the potientially aggregate src/dest
/// ptrs, copying all of the elements.
-static void CopyAggregate(MemRef DestLoc, MemRef SrcLoc, LLVMBuilder Builder)
{
+static void CopyAggregate(MemRef DestLoc, MemRef SrcLoc, LLVMBuilder Builder,
+ tree gccType) {
assert(DestLoc.Ptr-getType() == SrcLoc.Ptr-getType()
Cannot copy between two pointers of different type!);
const Type *ElTy =
@@ -1246,6 +1247,8 @@
const StructLayout *SL = getTargetData().getStructLayout(STy);
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
for (unsigned i = 0, e = STy-getNumElements(); i != e; ++i) {
+ if (gccType isPaddingElement(gccType, i))
+continue;
Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
Value *Idxs[2] = { Zero, Idx };
Value *DElPtr = Builder.CreateGEP(DestLoc.Ptr, Idxs, Idxs + 2, tmp);
@@ -1253,7 +1256,7 @@
unsigned Align = MinAlign(Alignment, SL-getElementOffset(i));
CopyAggregate(MemRef(DElPtr, Align, DestLoc.Volatile),
MemRef(SElPtr, Align, SrcLoc.Volatile),
-Builder);
+Builder, 0);
}
} else {
const ArrayType *ATy = castArrayType(ElTy);
@@ -1267,7 +1270,7 @@
unsigned Align = MinAlign(Alignment, i * EltSize);
CopyAggregate(MemRef(DElPtr, Align, DestLoc.Volatile),
MemRef(SElPtr, Align, SrcLoc.Volatile),
-Builder);
+Builder, 0);
}
}
}
@@ -1311,7 +1314,7 @@
CountAggregateElements(LLVMTy) = 8) {
DestLoc.Ptr = BitCastToType(DestLoc.Ptr, PointerType::getUnqual(LLVMTy));
SrcLoc.Ptr = BitCastToType(SrcLoc.Ptr, PointerType::getUnqual(LLVMTy));
- CopyAggregate(DestLoc, SrcLoc, Builder);
+ CopyAggregate(DestLoc, SrcLoc, Builder, type);
return;
}
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL:
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=47180r1=47179r2=47180view=diff
==
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Fri Feb 15 16:02:22 2008
@@ -116,7 +116,7 @@
/// Return true if and only if field no. N from struct type T is a padding
/// element added to match llvm struct type size and gcc struct type size.
-bool isPaddingElement(const Type *T, unsigned N);
+bool isPaddingElement(union tree_node*, unsigned N);
/// TypeConverter - Implement the converter from GCC types to LLVM types.
///
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=47180r1=47179r2=47180view=diff
==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Feb 15 16:02:22 2008
@@ -1577,13 +1577,13 @@
}
}
-std::mapconst Type *, StructTypeConversionInfo * StructTypeInfoMap;
+std::maptree, StructTypeConversionInfo * StructTypeInfoMap;
/// Return true if and only if field no. N from struct type T is a padding
/// element added to match llvm struct type size and gcc struct type size.
-bool isPaddingElement(const Type *Ty, unsigned index) {
+bool isPaddingElement(tree type, unsigned index) {
- StructTypeConversionInfo *Info = StructTypeInfoMap[Ty];
+ StructTypeConversionInfo *Info = StructTypeInfoMap[type];
// If info is not available then be conservative and return false.
if (!Info)
@@ -1600,10 +1600,10 @@
/// structs then adjust their PaddingElement bits. Padding
/// field in one struct may not be a padding field in another
/// struct.
-void adjustPaddingElement(const Type *OldTy, const Type *NewTy) {
+void adjustPaddingElement(tree oldtree, tree newtree) {
- StructTypeConversionInfo *OldInfo = StructTypeInfoMap[OldTy];
- StructTypeConversionInfo *NewInfo = StructTypeInfoMap[NewTy];
+ StructTypeConversionInfo *OldInfo = StructTypeInfoMap[oldtree];
+ StructTypeConversionInfo *NewInfo = StructTypeInfoMap[newtree];
if (!OldInfo || !NewInfo)
return;
@@