[llvm-commits] [poolalloc] r127474 - /poolalloc/trunk/lib/DSA/DataStructure.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Fri Mar 11 10:28:37 PST 2011
Author: aggarwa4
Date: Fri Mar 11 12:28:37 2011
New Revision: 127474
URL: http://llvm.org/viewvc/llvm-project?rev=127474&view=rev
Log:
Clang generates loads and stores that use struct types.
So as not to consider these types overlapping with their
own field accesses, we must just record the field types
at the right offset.
Modified:
poolalloc/trunk/lib/DSA/DataStructure.cpp
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=127474&r1=127473&r2=127474&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Fri Mar 11 12:28:37 2011
@@ -422,7 +422,23 @@
if (Offset + TD.getTypeAllocSize(NewTy) >= getSize())
growSize(Offset + TD.getTypeAllocSize(NewTy));
- TyMap[Offset] = getParentGraph()->getTypeSS().getOrCreate(TyMap[Offset], NewTy);
+ // Clang generates loads and stores of struct types.
+ // %tmp12 = load %struct.demand* %retval, align 1
+
+ // In such cases, merge type information for each struct field
+ // individually(at the appropriate offset), instead of the
+ // struct type.
+ if(NewTy->isStructTy()) {
+ const StructType *STy = cast<StructType>(NewTy);
+ const StructLayout *SL = TD.getStructLayout(cast<StructType>(STy));
+ unsigned count = 0;
+ for(Type::subtype_iterator ii = STy->element_begin(), ee = STy->element_end(); ii!= ee; ++ii, ++count) {
+ unsigned FieldOffset = SL->getElementOffset(count);
+ mergeTypeInfo(*ii, Offset + FieldOffset);
+ }
+ } else {
+ TyMap[Offset] = getParentGraph()->getTypeSS().getOrCreate(TyMap[Offset], NewTy);
+ }
assert(TyMap[Offset]);
}
More information about the llvm-commits
mailing list