llvm.org GIT mirror llvm / 5dc2b58
[SDAG] Fix Stale SDNode usage in visitAND Reorder CombineTo Calls to prevent potential use of deleted node. Fixes PR32372. Reviewers: jnspaulsson, RKSimon, uweigand, jonpa Reviewed By: jonpa Subscribers: jonpa, llvm-commits Differential Revision: https://reviews.llvm.org/D31346 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298920 91177308-0d34-0410-b5e6-96231b3b80d8 Nirav Dave 3 years ago
2 changed file(s) with 35 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
35353535 // If the load type was an EXTLOAD, convert to ZEXTLOAD in order to
35363536 // preserve semantics once we get rid of the AND.
35373537 SDValue NewLoad(Load, 0);
3538
3539 // Fold the AND away. NewLoad may get replaced immediately.
3540 CombineTo(N, NewLoad);
3541
35383542 if (Load->getExtensionType() == ISD::EXTLOAD) {
35393543 NewLoad = DAG.getLoad(Load->getAddressingMode(), ISD::ZEXTLOAD,
35403544 Load->getValueType(0), SDLoc(Load),
35513555 CombineTo(Load, NewLoad.getValue(0), NewLoad.getValue(1));
35523556 }
35533557 }
3554
3555 // Fold the AND away, taking care not to fold to the old load node if we
3556 // replaced it.
3557 CombineTo(N, (N0.getNode() == Load) ? NewLoad : N0);
35583558
35593559 return SDValue(N, 0); // Return N so it doesn't get rechecked!
35603560 }
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc %s -o - -mtriple=s390x-linux-gnu | FileCheck %s
2
3 define void @pr32372(i8*) {
4 ; CHECK-LABEL: pr32372:
5 ; CHECK: # BB#0: # %BB
6 ; CHECK-NEXT: llc %r1, 0(%r2)
7 ; CHECK-NEXT: mvhhi 0(%r1), -3825
8 ; CHECK-NEXT: llill %r0, 0
9 ; CHECK-NEXT: dlr %r0, %r1
10 ; CHECK-NEXT: .LBB0_1: # %CF251
11 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
12 ; CHECK-NEXT: j .LBB0_1
13 BB:
14 %L = load i8, i8* %0
15 store i16 -3825, i16* undef
16 %L5 = load i8, i8* %0
17 %B9 = urem i8 %L5, %L
18 %I107 = insertelement <8 x i8> zeroinitializer, i8 %B9, i32 7
19 %ZE141 = zext i8 %L5 to i16
20 br label %CF251
21
22 CF251: ; preds = %CF258, %CF251, %BB
23 %Shuff217 = shufflevector <8 x i8> zeroinitializer, <8 x i8> %I107, <8 x i32>
24 %Cmp227 = icmp sge i16 %ZE141, 0
25 br i1 %Cmp227, label %CF251, label %CF258
26
27 CF258: ; preds = %CF251
28 %Shuff230 = shufflevector <2 x i16> undef, <2 x i16> undef, <2 x i32>
29 br label %CF251
30 }