summaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-07-18 00:18:30 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-07-18 00:18:30 +0000
commite840434755e2165ac20ec55e9d5ff3d2defac2d2 (patch)
tree546353c849d6137556b5dfb7e90d317a7c37b42c /lib/Analysis/BasicAliasAnalysis.cpp
parente0125b678539029091e70695cf4219ec2c297a25 (diff)
downloadllvm-e840434755e2165ac20ec55e9d5ff3d2defac2d2.tar.gz
llvm-e840434755e2165ac20ec55e9d5ff3d2defac2d2.tar.bz2
llvm-e840434755e2165ac20ec55e9d5ff3d2defac2d2.tar.xz
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
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index c533f6d5ef..f95adb3292 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -143,8 +143,8 @@ static const Value *getUnderlyingObject(const Value *V) {
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 @@ static const Value *GetGEPOperands(const Value *V, std::vector<Value*> &GEPOps){
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 @@ static bool AddressMightEscape(const Value *V) {
//
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 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
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 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
// 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 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops,
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;