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

Chris Lattner lattner at cs.uiuc.edu
Tue Jul 20 20:57:05 PDT 2004



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.46 -> 1.47

---
Log message:

Do not ignore casts unless they are pointer-pointer casts.  This caused us 
to miscompile the SingleSource/Regression/C++/pointer_member.cpp program.


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

Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.47
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46	Sat Jul 17 19:18:30 2004
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Tue Jul 20 22:56:54 2004
@@ -240,10 +240,12 @@
                           const Value *V2, unsigned V2Size) {
   // Strip off any constant expression casts if they exist
   if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V1))
-    if (CE->getOpcode() == Instruction::Cast)
+    if (CE->getOpcode() == Instruction::Cast &&
+        isa<PointerType>(CE->getOperand(0)->getType()))
       V1 = CE->getOperand(0);
   if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V2))
-    if (CE->getOpcode() == Instruction::Cast)
+    if (CE->getOpcode() == Instruction::Cast &&
+        isa<PointerType>(CE->getOperand(0)->getType()))
       V2 = CE->getOperand(0);
 
   // Are we checking for alias of the same value?
@@ -255,9 +257,11 @@
 
   // Strip off cast instructions...
   if (const Instruction *I = dyn_cast<CastInst>(V1))
-    return alias(I->getOperand(0), V1Size, V2, V2Size);
+    if (isa<PointerType>(I->getOperand(0)->getType()))
+      return alias(I->getOperand(0), V1Size, V2, V2Size);
   if (const Instruction *I = dyn_cast<CastInst>(V2))
-    return alias(V1, V1Size, I->getOperand(0), V2Size);
+    if (isa<PointerType>(I->getOperand(0)->getType()))
+      return alias(V1, V1Size, I->getOperand(0), V2Size);
 
   // Figure out what objects these things are pointing to if we can...
   const Value *O1 = getUnderlyingObject(V1);





More information about the llvm-commits mailing list