[llvm] r268774 - SDAG: Don't leave dangling dead nodes after SelectCodeCommon
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 11:42:16 PDT 2016
Author: bogner
Date: Fri May 6 13:42:16 2016
New Revision: 268774
URL: http://llvm.org/viewvc/llvm-project?rev=268774&view=rev
Log:
SDAG: Don't leave dangling dead nodes after SelectCodeCommon
Relying on the caller to clean up after we've replaced all uses of a
node won't work when we've migrated to the `void Select(...)` API.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=268774&r1=268773&r2=268774&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri May 6 13:42:16 2016
@@ -2179,7 +2179,7 @@ void SelectionDAGISel::UpdateChains(
CurDAG->ReplaceAllUsesOfValueWith(ChainVal, InputChain);
// If the node became dead and we haven't already seen it, delete it.
- if (ChainNode->use_empty() &&
+ if (ChainNode != NodeToMatch && ChainNode->use_empty() &&
!std::count(NowDeadNodes.begin(), NowDeadNodes.end(), ChainNode))
NowDeadNodes.push_back(ChainNode);
}
@@ -2741,6 +2741,7 @@ SelectCodeCommon(SDNode *NodeToMatch, co
case ISD::AssertZext:
CurDAG->ReplaceAllUsesOfValueWith(SDValue(NodeToMatch, 0),
NodeToMatch->getOperand(0));
+ CurDAG->RemoveDeadNode(NodeToMatch);
return nullptr;
case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch);
case ISD::READ_REGISTER: return Select_READ_REGISTER(NodeToMatch);
@@ -3474,6 +3475,7 @@ SelectCodeCommon(SDNode *NodeToMatch, co
assert(NodeToMatch->use_empty() &&
"Didn't replace all uses of the node?");
+ CurDAG->RemoveDeadNode(NodeToMatch);
// FIXME: We just return here, which interacts correctly with SelectRoot
// above. We should fix this to not return an SDNode* anymore.
More information about the llvm-commits
mailing list