bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14942 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index c533f6d..f95adb3 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -143,8 +143,8 @@
     if (CE->getOpcode() == Instruction::Cast ||
         CE->getOpcode() == Instruction::GetElementPtr)
       return getUnderlyingObject(CE->getOperand(0));
-  } else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V)) {
-    return CPR->getValue();
+  } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
+    return GV;
   }
   return 0;
 }
@@ -166,7 +166,7 @@
   V = cast<User>(V)->getOperand(0);
 
   while (const User *G = isGEP(V)) {
-    if (!isa<Constant>(GEPOps[0]) ||
+    if (!isa<Constant>(GEPOps[0]) || isa<GlobalValue>(GEPOps[0]) ||
         !cast<Constant>(GEPOps[0])->isNullValue())
       break;  // Don't handle folding arbitrary pointer offsets yet...
     GEPOps.erase(GEPOps.begin());   // Drop the zero index
@@ -217,7 +217,7 @@
 //
 AliasAnalysis::ModRefResult
 BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
-  if (!isa<Constant>(P) && !isa<GlobalValue>(P))
+  if (!isa<Constant>(P))
     if (const AllocationInst *AI =
                   dyn_cast_or_null<AllocationInst>(getUnderlyingObject(P))) {
       // Okay, the pointer is to a stack allocated object.  If we can prove that
@@ -246,12 +246,6 @@
     if (CE->getOpcode() == Instruction::Cast)
       V2 = CE->getOperand(0);
 
-  // Strip off constant pointer refs if they exist
-  if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V1))
-    V1 = CPR->getValue();
-  if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V2))
-    V2 = CPR->getValue();
-
   // Are we checking for alias of the same value?
   if (V1 == V2) return MustAlias;
 
@@ -380,7 +374,7 @@
           // the arguments provided, except substitute 0's for any variable
           // indexes we find...
           for (unsigned i = 0; i != GEPOperands.size(); ++i)
-            if (!isa<Constant>(GEPOperands[i]) ||
+            if (!isa<Constant>(GEPOperands[i]) || isa<GlobalValue>(GEPOperands[i]) ||
                 isa<ConstantExpr>(GEPOperands[i]))
               GEPOperands[i] =Constant::getNullValue(GEPOperands[i]->getType());
           int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(),
@@ -453,7 +447,7 @@
     
     bool AllAreZeros = true;
     for (unsigned i = UnequalOper; i != MaxOperands; ++i)
-      if (!isa<Constant>(GEP1Ops[i]) ||
+      if (!isa<Constant>(GEP1Ops[i]) || 
           !cast<Constant>(GEP1Ops[i])->isNullValue()) {
         AllAreZeros = false;
         break;