[llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp ScalarEvolution.cpp
LLVM
llvm at cs.uiuc.edu
Sat Jul 17 17:18:40 PDT 2004
Changes in directory llvm/lib/Analysis:
BasicAliasAnalysis.cpp updated: 1.45 -> 1.46
ScalarEvolution.cpp updated: 1.22 -> 1.23
---
Log message:
bug 122: http://llvm.cs.uiuc.edu/PR122 :
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
---
Diffs of the changes: (+10 -18)
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.45 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.45 Wed Jul 14 15:27:12 2004
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Sat Jul 17 19:18:30 2004
@@ -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;
Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.22 llvm/lib/Analysis/ScalarEvolution.cpp:1.23
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.22 Thu Jun 24 01:51:27 2004
+++ llvm/lib/Analysis/ScalarEvolution.cpp Sat Jul 17 19:18:30 2004
@@ -1498,9 +1498,9 @@
case Instruction::Select:
return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
case Instruction::Call:
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Operands[0])) {
+ if (Function *GV = dyn_cast<Function>(Operands[0])) {
Operands.erase(Operands.begin());
- return ConstantFoldCall(cast<Function>(CPR->getValue()), Operands);
+ return ConstantFoldCall(cast<Function>(GV), Operands);
}
return 0;
@@ -1560,9 +1560,9 @@
/// reason, return null.
static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
if (isa<PHINode>(V)) return PHIVal;
- if (Constant *C = dyn_cast<Constant>(V)) return C;
if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
- return ConstantPointerRef::get(GV);
+ return GV;
+ if (Constant *C = dyn_cast<Constant>(V)) return C;
Instruction *I = cast<Instruction>(V);
std::vector<Constant*> Operands;
@@ -1718,8 +1718,6 @@
Value *Op = I->getOperand(i);
if (Constant *C = dyn_cast<Constant>(Op)) {
Operands.push_back(C);
- } else if (GlobalValue *GV = dyn_cast<GlobalValue>(Op)) {
- Operands.push_back(ConstantPointerRef::get(GV));
} else {
SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(OpV))
More information about the llvm-commits
mailing list