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

Chris Lattner lattner at cs.uiuc.edu
Thu Dec 11 00:03:01 PST 2003


Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.20 -> 1.21

---
Log message:

Realize the gep P, <zeros> must aliases P.
This is a partial fix for PR 86


---
Diffs of the changes:  (+11 -1)

Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.20 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.21
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.20	Wed Dec 10 23:44:59 2003
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Thu Dec 11 00:02:00 2003
@@ -175,12 +175,22 @@
         // If there is at least one non-zero constant index, we know they cannot
         // alias.
         bool ConstantFound = false;
+        bool AllZerosFound = true;
         for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
-          if (const Constant *C = dyn_cast<Constant>(GEP->getOperand(i)))
+          if (const Constant *C = dyn_cast<Constant>(GEP->getOperand(i))) {
             if (!C->isNullValue()) {
               ConstantFound = true;
               break;
+            }
+          } else {
+            AllZerosFound = false;
           }
+
+        // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases
+        // the ptr, the end result is a must alias also.
+        if (AllZerosFound)
+          return MustAlias;
+
         if (ConstantFound) {
           if (V2Size <= 1 && V1Size <= 1)  // Just pointer check?
             return NoAlias;





More information about the llvm-commits mailing list