diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:31:05 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:31:05 +0000 |
commit | c5afc9512bfe9d5c1695d064be940d7cf58e8e1d (patch) | |
tree | 08abd4e89c920b849a24973c43d8c7af5b00eb3e /llvm/lib/Transforms | |
parent | 9e855c68325d51783e317ebdb33aacc0505f3354 (diff) | |
download | bcm5719-llvm-c5afc9512bfe9d5c1695d064be940d7cf58e8e1d.tar.gz bcm5719-llvm-c5afc9512bfe9d5c1695d064be940d7cf58e8e1d.zip |
bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Correct isa<Constant> for GlobalValue subclass
llvm-svn: 14947
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 5073f8fde27..dc141d5b54e 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -175,13 +175,13 @@ private: hash_map<Value*, InstVal>::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map - if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant + if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { + // The address of a global is a constant... + ValueState[V].markConstant(GV); + } else if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant ValueState[CPV].markConstant(CPV); } else if (isa<Argument>(V)) { // Arguments are overdefined ValueState[V].markOverdefined(); - } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { - // The address of a global is a constant... - ValueState[V].markConstant(ConstantPointerRef::get(GV)); } // All others are underdefined by default... return ValueState[V]; @@ -784,9 +784,6 @@ void SCCP::visitLoadInst(LoadInst &I) { return; } - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr)) - Ptr = CPR->getValue(); - // Transform load (constant global) into the value loaded. if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) if (GV->isConstant() && !GV->isExternal()) { @@ -797,15 +794,13 @@ void SCCP::visitLoadInst(LoadInst &I) { // Transform load (constantexpr_GEP global, 0, ...) into the value loaded. if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr)) if (CE->getOpcode() == Instruction::GetElementPtr) - if (ConstantPointerRef *G - = dyn_cast<ConstantPointerRef>(CE->getOperand(0))) - if (GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getValue())) - if (GV->isConstant() && !GV->isExternal()) - if (Constant *V = - GetGEPGlobalInitializer(GV->getInitializer(), CE)) { - markConstant(IV, &I, V); - return; - } + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0))) + if (GV->isConstant() && !GV->isExternal()) + if (Constant *V = + GetGEPGlobalInitializer(GV->getInitializer(), CE)) { + markConstant(IV, &I, V); + return; + } } // Otherwise we cannot say for certain what value this load will produce. |