From 11d61613af577401dcff605d0ed302b91f657713 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 30 Nov 2005 02:49:21 +0000 Subject: Fixed a bug introduced by my last commit: TargetGlobalValues should key on GlobalValue * and index pair. Update getGlobalAddress() for symmetry. llvm-svn: 24524 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 606ed5234b4..8aa2bc660a8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -283,12 +283,18 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) { Erased = CondCodeNodes[cast(N)->get()] != 0; CondCodeNodes[cast(N)->get()] = 0; break; - case ISD::GlobalAddress: - Erased = GlobalValues.erase(cast(N)->getGlobal()); + case ISD::GlobalAddress: { + GlobalAddressSDNode *GN = cast(N); + Erased = GlobalValues.erase(std::make_pair(GN->getGlobal(), + GN->getOffset())); break; - case ISD::TargetGlobalAddress: - Erased =TargetGlobalValues.erase(cast(N)->getGlobal()); + } + case ISD::TargetGlobalAddress: { + GlobalAddressSDNode *GN = cast(N); + Erased =TargetGlobalValues.erase(std::make_pair(GN->getGlobal(), + GN->getOffset())); break; + } case ISD::FrameIndex: Erased = FrameIndices.erase(cast(N)->getIndex()); break; @@ -491,8 +497,8 @@ SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT) { SDOperand SelectionDAG::getGlobalAddress(const GlobalValue *GV, - MVT::ValueType VT) { - SDNode *&N = GlobalValues[GV]; + MVT::ValueType VT, int offset) { + SDNode *&N = GlobalValues[std::make_pair(GV, offset)]; if (N) return SDOperand(N, 0); N = new GlobalAddressSDNode(false, GV, VT); AllNodes.push_back(N); @@ -501,7 +507,7 @@ SDOperand SelectionDAG::getGlobalAddress(const GlobalValue *GV, SDOperand SelectionDAG::getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT, int offset) { - SDNode *&N = TargetGlobalValues[GV]; + SDNode *&N = TargetGlobalValues[std::make_pair(GV, offset)]; if (N) return SDOperand(N, 0); N = new GlobalAddressSDNode(true, GV, VT, offset); AllNodes.push_back(N); -- cgit v1.2.3