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

Chris Lattner sabre at nondot.org
Fri Nov 3 13:59:02 PST 2006



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.88 -> 1.89
---
Log message:

Fix BasicAA/2006-11-03-BasicAAVectorCrash.ll by handling out-of-range
vector accesses like we handle out-of-range array accesses.


---
Diffs of the changes:  (+20 -8)

 BasicAliasAnalysis.cpp |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.88 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.89
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.88	Thu Nov  2 14:25:49 2006
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Fri Nov  3 15:58:48 2006
@@ -555,20 +555,21 @@
           }
           
           if (G1OC != G2OC) {
-            // Handle the "be careful" case above: if this is an array
+            // Handle the "be careful" case above: if this is an array/packed
             // subscript, scan for a subsequent variable array index.
-            if (isa<ArrayType>(BasePtr1Ty))  {
-              const Type *NextTy =cast<ArrayType>(BasePtr1Ty)->getElementType();
+            if (isa<SequentialType>(BasePtr1Ty))  {
+              const Type *NextTy =
+                cast<SequentialType>(BasePtr1Ty)->getElementType();
               bool isBadCase = false;
               
               for (unsigned Idx = FirstConstantOper+1;
-                   Idx != MinOperands && isa<ArrayType>(NextTy); ++Idx) {
+                   Idx != MinOperands && isa<SequentialType>(NextTy); ++Idx) {
                 const Value *V1 = GEP1Ops[Idx], *V2 = GEP2Ops[Idx];
                 if (!isa<Constant>(V1) || !isa<Constant>(V2)) {
                   isBadCase = true;
                   break;
                 }
-                NextTy = cast<ArrayType>(NextTy)->getElementType();
+                NextTy = cast<SequentialType>(NextTy)->getElementType();
               }
               
               if (isBadCase) G1OC = 0;
@@ -668,10 +669,14 @@
       if (Op1) {
         if (const ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) {
           // If this is an array index, make sure the array element is in range.
-          if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
+          if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) {
             if (Op1C->getZExtValue() >= AT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
-
+          } else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty)) {
+            if (Op1C->getZExtValue() >= PT->getNumElements())
+              return MayAlias;  // Be conservative with out-of-range accesses
+          }
+          
         } else {
           // GEP1 is known to produce a value less than GEP2.  To be
           // conservatively correct, we must assume the largest possible
@@ -685,15 +690,22 @@
           //
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
             GEP1Ops[i] = ConstantInt::get(Type::LongTy, AT->getNumElements()-1);
+          else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty))
+            GEP1Ops[i] = ConstantInt::get(Type::LongTy, PT->getNumElements()-1);
+
         }
       }
 
       if (Op2) {
         if (const ConstantInt *Op2C = dyn_cast<ConstantInt>(Op2)) {
           // If this is an array index, make sure the array element is in range.
-          if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
+          if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) {
             if (Op2C->getZExtValue() >= AT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
+          } else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty)) {
+            if (Op2C->getZExtValue() >= PT->getNumElements())
+              return MayAlias;  // Be conservative with out-of-range accesses
+          }
         } else {  // Conservatively assume the minimum value for this index
           GEP2Ops[i] = Constant::getNullValue(Op2->getType());
         }






More information about the llvm-commits mailing list