Fixed https://github.com/llvm/llvm-project/issues/59891
Please also commit for me since I dont have commit access
Differential D141256
[DAGCombine]Don't check for Undef/Poison if the node is deleted Naville on Jan 8 2023, 11:14 PM. Authored by
Details Fixed https://github.com/llvm/llvm-project/issues/59891 Please also commit for me since I dont have commit access
Diff Detail
Event Timeline
Comment Actions Can confirm no DELETED_NODE exists before the entire DAG processing logic, SelectionDAG has 12 nodes: t0: ch,glue = EntryToken t2: i64,ch = CopyFromReg t0, Register:i64 %0 t3: i64 = freeze t2 t4: i1 = truncate t3 t5: i1 = truncate t2 t6: i1 = xor t4, t5 t7: i1 = freeze t6 t9: i32 = zero_extend t7 t11: ch,glue = CopyToReg t0, Register:i32 $w0, t9 t12: ch = AArch64ISD::RET_FLAG t11, Register:i32 $w0, t11:1
Comment Actions This isn't right, we'll no longer be sure that we dropped flags. diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 78cbfe1356f7..a87415c3f5ed 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -14289,6 +14289,7 @@ SDValue DAGCombiner::visitBUILD_PAIR(SDNode *N) { SDValue DAGCombiner::visitFREEZE(SDNode *N) { SDValue N0 = N->getOperand(0); + HandleSDNode N0Handle(N0); if (DAG.isGuaranteedNotToBeUndefOrPoison(N0, /*PoisonOnly*/ false)) return N0; Comment Actions Or better yet, diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 78cbfe1356f7..82fdbf1cc790 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -14341,6 +14341,9 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) { MaybePoisonOperand); } } + // The whole node may have been updated, so the value we were holding + // may no longer be valid. Re-fetch the operand we're `freeze`ing. + N0 = N->getOperand(0); // Finally, recreate the node, it's operands were updated to use // frozen operands, so we just need to use it's "original" operands. |
(style) early out instead of a if-else chain