[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Wed Apr 19 08:34:46 PDT 2006
Changes in directory llvm/lib/Analysis/DataStructure:
DataStructure.cpp updated: 1.244 -> 1.245
---
Log message:
Another simple case type merge case to try
---
Diffs of the changes: (+24 -0)
DataStructure.cpp | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+)
Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.244 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.245
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.244 Mon Mar 27 17:39:58 2006
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Wed Apr 19 10:34:34 2006
@@ -532,6 +532,30 @@
return mergeTypeInfo(STy, 0);
}
+ //Ty: struct { t1, t2, t3 ... tn}
+ //NewTy T offset x
+ //try merge with NewTy: struct : {t1, t2, T} if offset lands on a field in Ty
+ if (isa<StructType>(Ty)) {
+ DEBUG(std::cerr << "Ty: " << *Ty << "\nNewTy: " << *NewTy << "@" << Offset << "\n");
+ unsigned O = 0;
+ const StructType *STy = cast<StructType>(Ty);
+ const StructLayout &SL = *TD.getStructLayout(STy);
+ unsigned i = SL.getElementContainingOffset(Offset);
+ //Either we hit it exactly or give up
+ if (SL.MemberOffsets[i] != Offset) {
+ if (FoldIfIncompatible) foldNodeCompletely();
+ return true;
+ }
+ std::vector<const Type*> nt;
+ for (unsigned x = 0; x < i; ++x)
+ nt.push_back(STy->getElementType(x));
+ nt.push_back(NewTy);
+ //and merge
+ STy = StructType::get(nt);
+ DEBUG(std::cerr << "Trying with: " << *STy << "\n");
+ return mergeTypeInfo(STy, 0);
+ }
+
std::cerr << "UNIMP: Trying to merge a growth type into "
<< "offset != 0: Collapsing!\n";
abort();
More information about the llvm-commits
mailing list