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

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 26 12:02:05 PST 2004



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.56 -> 1.57
---
Log message:

The trick with globals actually works with allocas and malloc too


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

Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.56 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.57
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.56	Fri Nov 26 13:20:01 2004
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Fri Nov 26 14:01:48 2004
@@ -290,13 +290,13 @@
     if (!isa<Argument>(O1) && isa<ConstantPointerNull>(V2))
       return NoAlias;                    // Unique values don't alias null
 
-    if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O1))
-      if (GV->getType()->getElementType()->isSized()) {
+    if (isa<GlobalVariable>(O1) || isa<AllocationInst>(O1))
+      if (cast<PointerType>(O1->getType())->getElementType()->isSized()) {
         // If the size of the other access is larger than the total size of the
-        // global, it cannot be accessing the global (it's undefined to load or
-        // store bytes after the global).
-        unsigned GlobalSize =
-          getTargetData().getTypeSize(GV->getType()->getElementType());
+        // global/alloca/malloc, it cannot be accessing the global (it's
+        // undefined to load or store bytes before or after an object).
+        const Type *ElTy = cast<PointerType>(O1->getType())->getElementType();
+        unsigned GlobalSize = getTargetData().getTypeSize(ElTy);
         if (GlobalSize < V2Size)
           return NoAlias;
       }
@@ -306,13 +306,13 @@
     if (!isa<Argument>(O2) && isa<ConstantPointerNull>(V1))
       return NoAlias;                    // Unique values don't alias null
 
-    if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O2))
-      if (GV->getType()->getElementType()->isSized()) {
+    if (isa<GlobalVariable>(O2) || isa<AllocationInst>(O2))
+      if (cast<PointerType>(O2->getType())->getElementType()->isSized()) {
         // If the size of the other access is larger than the total size of the
-        // global, it cannot be accessing the global (it's undefined to load or
-        // store bytes after the global).
-        unsigned GlobalSize =
-          getTargetData().getTypeSize(GV->getType()->getElementType());
+        // global/alloca/malloc, it cannot be accessing the object (it's
+        // undefined to load or store bytes before or after an object).
+        const Type *ElTy = cast<PointerType>(O2->getType())->getElementType();
+        unsigned GlobalSize = getTargetData().getTypeSize(ElTy);
         if (GlobalSize < V1Size)
           return NoAlias;
       }






More information about the llvm-commits mailing list