From 1e56c54f41ca2e97e0cbbfd1014c2652f0ec3424 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 9 Feb 2003 23:04:12 +0000 Subject: [PATCH] Don't insert null entries into the scalar map for constexpr (cast null to Ty) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5523 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/Local.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 559d79aa8fa..b54827699ed 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -174,16 +174,22 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) { return NH = getValueDest(*CPR->getValue()); } else if (ConstantExpr *CE = dyn_cast(C)) { if (CE->getOpcode() == Instruction::Cast) - return NH = getValueDest(*CE->getOperand(0)); - if (CE->getOpcode() == Instruction::GetElementPtr) { + NH = getValueDest(*CE->getOperand(0)); + else if (CE->getOpcode() == Instruction::GetElementPtr) { visitGetElementPtrInst(*CE); hash_map::iterator I = ScalarMap.find(CE); assert(I != ScalarMap.end() && "GEP didn't get processed right?"); - return NH = I->second; + NH = I->second; + } else { + // This returns a conservative unknown node for any unhandled ConstExpr + return NH = createNode(DSNode::UnknownNode); } + if (NH.getNode() == 0) { // (getelementptr null, X) returns null + ScalarMap.erase(V); + return 0; + } + return NH; - // This returns a conservative unknown node for any unhandled ConstExpr - return NH = createNode(DSNode::UnknownNode); } else if (ConstantIntegral *CI = dyn_cast(C)) { // Random constants are unknown mem return NH = createNode(DSNode::UnknownNode);