From 0a4703b5ece8df0ed794d351a919aec490b539bb Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Wed, 1 Mar 2017 20:19:38 +0000 Subject: [DAG] Prevent Stale nodes from entering worklist Add check that deleted nodes do not get added to worklist. This can occur when a node's operand is simplified to an existing node. This fixes PR32108. Reviewers: jyknight, hfinkel, chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30506 llvm-svn: 296668 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 547655f9f7b..9b467d20e55 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -129,6 +129,9 @@ namespace { /// Add to the worklist making sure its instance is at the back (next to be /// processed.) void AddToWorklist(SDNode *N) { + assert(N->getOpcode() != ISD::DELETED_NODE && + "Deleted Node added to Worklist"); + // Skip handle nodes as they can't usefully be combined and confuse the // zero-use deletion strategy. if (N->getOpcode() == ISD::HANDLENODE) @@ -12619,10 +12622,13 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { Value, APInt::getLowBitsSet(Value.getScalarValueSizeInBits(), ST->getMemoryVT().getScalarSizeInBits()))) { - // Re-visit the store if anything changed; SimplifyDemandedBits - // will add Value's node back to the worklist if necessary, but - // we also need to re-visit the Store node itself. - AddToWorklist(N); + // Re-visit the store if anything changed and the store hasn't + // been merged with another node (N is deleted); + // SimplifyDemandedBits will add Value's node back to the + // worklist if necessary, but we also need to re-visit the Store + // node itself. + if (N->getOpcode() != ISD::DELETED_NODE) + AddToWorklist(N); return SDValue(N, 0); } } -- cgit v1.2.3