aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-09 20:14:03 +0000
committerChris Lattner <sabre@nondot.org>2002-11-09 20:14:03 +0000
commit2cfbaaf3b9582136abae6cde488f447f6a44ca11 (patch)
tree661ec3dd8fa767e5079466eb5cbc40c1581c1242 /lib/Analysis/DataStructure/Local.cpp
parent2e4f9bf86e5d3b86c4a24a58138c630c861d9def (diff)
Don't put constants into the scalar map!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--lib/Analysis/DataStructure/Local.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index 0c0c6afd88..e731d5cb7b 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -150,30 +150,34 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
if (V == Constant::getNullValue(V->getType()))
return 0; // Null doesn't point to anything, don't add to ScalarMap!
- DSNodeHandle &NH = ScalarMap[V];
- if (NH.getNode())
- return NH; // Already have a node? Just return it...
-
if (Constant *C = dyn_cast<Constant>(V))
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
- return NH = getValueDest(*CPR->getValue());
+ return getValueDest(*CPR->getValue());
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (CE->getOpcode() == Instruction::Cast)
- return NH = getValueDest(*CE->getOperand(0));
+ return getValueDest(*CE->getOperand(0));
if (CE->getOpcode() == Instruction::GetElementPtr) {
visitGetElementPtrInst(*CE);
- return ScalarMap[CE];
+ std::map<Value*, DSNodeHandle>::iterator I = ScalarMap.find(CE);
+ assert(I != ScalarMap.end() && "GEP didn't get processed right?");
+ DSNodeHandle NH = I->second;
+ ScalarMap.erase(I); // Remove constant from scalarmap
+ return NH;
}
// This returns a conservative unknown node for any unhandled ConstExpr
- return NH = createNode(DSNode::UnknownNode);
+ return createNode(DSNode::UnknownNode);
} else if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(C)) {
// Random constants are unknown mem
- return NH = createNode(DSNode::UnknownNode);
+ return createNode(DSNode::UnknownNode);
} else {
assert(0 && "Unknown constant type!");
}
+ DSNodeHandle &NH = ScalarMap[V];
+ if (NH.getNode())
+ return NH; // Already have a node? Just return it...
+
// Otherwise we need to create a new node to point to...
DSNode *N;
if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {