[DAGCombiner] visitFREEZE: Early exit when N is deleted (#128161) · llvm/llvm-project@69ee30f (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -16170,11 +16170,13 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) { | ||
16170 | 16170 | DAG.UpdateNodeOperands(FrozenMaybePoisonOperand.getNode(), |
16171 | 16171 | MaybePoisonOperand); |
16172 | 16172 | } |
16173 | + | |
16174 | + // This node has been merged with another. | |
16175 | + if (N->getOpcode() == ISD::DELETED_NODE) | |
16176 | + return SDValue(N, 0); | |
16173 | 16177 | } |
16174 | 16178 | |
16175 | - // This node has been merged with another. | |
16176 | - if (N->getOpcode() == ISD::DELETED_NODE) | |
16177 | - return SDValue(N, 0); | |
16179 | + assert(N->getOpcode() != ISD::DELETED_NODE && "Node was deleted!"); | |
16178 | 16180 | |
16179 | 16181 | // The whole node may have been updated, so the value we were holding |
16180 | 16182 | // may no longer be valid. Re-fetch the operand we're `freeze`ing. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | |
2 | +; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s | |
3 | + | |
4 | +@g_1 = external global i8 | |
5 | +@g_2 = external global i8 | |
6 | + | |
7 | +; Make sure we don't crash on this test. | |
8 | + | |
9 | +define i1 @test(i1 %cmp1, i32 %x) { | |
10 | +; CHECK-LABEL: test: | |
11 | +; CHECK: # %bb.0: # %entry | |
12 | +; CHECK-NEXT: movq g_2@GOTPCREL(%rip), %rcx | |
13 | +; CHECK-NEXT: xorl %eax, %eax | |
14 | +; CHECK-NEXT: cmpq %rcx, g_1@GOTPCREL(%rip) | |
15 | +; CHECK-NEXT: setne %al | |
16 | +; CHECK-NEXT: cmpl %eax, %esi | |
17 | +; CHECK-NEXT: setb %cl | |
18 | +; CHECK-NEXT: orb %cl, %al | |
19 | +; CHECK-NEXT: andb %dil, %al | |
20 | +; CHECK-NEXT: # kill: def alkilledal killed alkilledal killed $eax | |
21 | +; CHECK-NEXT: retq | |
22 | +entry: | |
23 | +%cmp2 = icmp ne ptr @g_1, @g_2 | |
24 | +%fr = freeze ptr @g_1 | |
25 | +%cmp3 = icmp ne ptr %fr, @g_2 | |
26 | +%ext1 = zext i1 %cmp3 to i32 | |
27 | +%sel1 = select i1 %cmp1, i1 %cmp2, i1 false | |
28 | +%cmp4 = icmp ult i32 %x, %ext1 | |
29 | +%sel3 = select i1 %cmp1, i1 %cmp4, i1 false | |
30 | +%or = or i1 %sel1, %sel3 | |
31 | +ret i1 %or | |
32 | +} |