[llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Mar 4 13:48:13 PST 2006



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.77 -> 1.78
---
Log message:

Fix a crash compiling Obsequi


---
Diffs of the changes:  (+12 -5)

 BasicAliasAnalysis.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.77 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.78
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.77	Fri Mar  3 20:06:34 2006
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Sat Mar  4 15:48:01 2006
@@ -637,17 +637,24 @@
   // than the first constant index of GEP2.
 
   // Advance BasePtr[12]Ty over this first differing constant operand.
-  BasePtr2Ty = cast<CompositeType>(BasePtr1Ty)->getTypeAtIndex(GEP2Ops[FirstConstantOper]);
-  BasePtr1Ty = cast<CompositeType>(BasePtr1Ty)->getTypeAtIndex(GEP1Ops[FirstConstantOper]);
+  BasePtr2Ty = cast<CompositeType>(BasePtr1Ty)->
+      getTypeAtIndex(GEP2Ops[FirstConstantOper]);
+  BasePtr1Ty = cast<CompositeType>(BasePtr1Ty)->
+      getTypeAtIndex(GEP1Ops[FirstConstantOper]);
 
   // We are going to be using TargetData::getIndexedOffset to determine the
   // offset that each of the GEP's is reaching.  To do this, we have to convert
   // all variable references to constant references.  To do this, we convert the
-  // initial equal sequence of variables into constant zeros to start with.
-  for (unsigned i = 0; i != FirstConstantOper; ++i)
-    if (!isa<ConstantInt>(GEP1Ops[i]) || !isa<ConstantInt>(GEP2Ops[i]))
+  // initial sequence of array subscripts into constant zeros to start with.
+  const Type *ZeroIdxTy = GEPPointerTy;
+  for (unsigned i = 0; i != FirstConstantOper; ++i) {
+    if (!isa<StructType>(ZeroIdxTy))
       GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::UIntTy);
 
+    if (const CompositeType *CT = dyn_cast<CompositeType>(ZeroIdxTy))
+      ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]);
+  }
+
   // We know that GEP1Ops[FirstConstantOper] & GEP2Ops[FirstConstantOper] are ok
 
   // Loop over the rest of the operands...






More information about the llvm-commits mailing list