llvm.org GIT mirror llvm / 7824530
NewGVN: Fix PR33204 - We need to add memory users when we bypass memorydefs for loads, not just when we do it for stores. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311829 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Berlin 2 years ago
2 changed file(s) with 85 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
12371237 if (EnableStoreRefinement)
12381238 StoreRHS = MSSAWalker->getClobberingMemoryAccess(StoreAccess);
12391239 // If we bypassed the use-def chains, make sure we add a use.
1240 StoreRHS = lookupMemoryLeader(StoreRHS);
12401241 if (StoreRHS != StoreAccess->getDefiningAccess())
12411242 addMemoryUsers(StoreRHS, StoreAccess);
1242 StoreRHS = lookupMemoryLeader(StoreRHS);
12431243 // If we are defined by ourselves, use the live on entry def.
12441244 if (StoreRHS == StoreAccess)
12451245 StoreRHS = MSSA->getLiveOnEntryDef();
13891389 }
13901390 }
13911391
1392 const Expression *E = createLoadExpression(LI->getType(), LoadAddressLeader,
1392 const auto *LE = createLoadExpression(LI->getType(), LoadAddressLeader,
13931393 LI, DefiningAccess);
1394 return E;
1394 // If our MemoryLeader is not our defining access, add a use to the
1395 // MemoryLeader, so that we get reprocessed when it changes.
1396 if (LE->getMemoryLeader() != DefiningAccess)
1397 addMemoryUsers(LE->getMemoryLeader(), OriginalAccess);
1398 return LE;
13951399 }
13961400
13971401 const Expression *
20242028 const MemoryAccess *NewGVN::getNextMemoryLeader(CongruenceClass *CC) const {
20252029 // TODO: If this ends up to slow, we can maintain a next memory leader like we
20262030 // do for regular leaders.
2027 // Make sure there will be a leader to find
2031 // Make sure there will be a leader to find.
20282032 assert(!CC->definesNoMemory() && "Can't get next leader if there is none");
20292033 if (CC->getStoreCount() > 0) {
20302034 if (auto *NL = dyn_cast_or_null(CC->getNextLeader().first))
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -newgvn -S %s | FileCheck %s
2 ; Ensure that loads that bypass memory def-use chains get added as users of the new
3 ; MemoryDef. Otherwise this test will not pass memory verification because the value
4 ; of the load will not be reprocessed until verification.
5 ; ModuleID = 'bugpoint-reduced-simplified.bc'
6 source_filename = "bugpoint-output-f242c4f.bc"
7 target triple = "x86_64-apple-darwin16.7.0"
8
9 @global = external global i32 #0
10 @global.1 = external global i32 #0
11
12 define void @hoge(i32 %arg) {
13 ; CHECK-LABEL: @hoge(
14 ; CHECK-NEXT: bb:
15 ; CHECK-NEXT: br label [[BB2:%.*]]
16 ; CHECK: bb1:
17 ; CHECK-NEXT: br label [[BB2]]
18 ; CHECK: bb2:
19 ; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ 0, [[BB1:%.*]] ], [ [[ARG:%.*]], [[BB:%.*]] ]
20 ; CHECK-NEXT: br label [[BB6:%.*]]
21 ; CHECK: bb3:
22 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* @global, !h !0
23 ; CHECK-NEXT: unreachable
24 ; CHECK: bb6:
25 ; CHECK-NEXT: store i32 [[TMP]], i32* @global.1, !h !0
26 ; CHECK-NEXT: br i1 undef, label [[BB7:%.*]], label [[BB1]]
27 ; CHECK: bb7:
28 ; CHECK-NEXT: br i1 undef, label [[BB10:%.*]], label [[BB8:%.*]]
29 ; CHECK: bb8:
30 ; CHECK-NEXT: br i1 false, label [[BB9:%.*]], label [[BB3:%.*]]
31 ; CHECK: bb9:
32 ; CHECK-NEXT: store i8 undef, i8* null
33 ; CHECK-NEXT: br label [[BB3]]
34 ; CHECK: bb10:
35 ; CHECK-NEXT: store i32 0, i32* @global, !h !0
36 ; CHECK-NEXT: br label [[BB7]]
37 ;
38 bb:
39 br label %bb2
40
41 bb1: ; preds = %bb6
42 br label %bb2
43
44 bb2: ; preds = %bb1, %bb
45 %tmp = phi i32 [ 0, %bb1 ], [ %arg, %bb ]
46 br label %bb6
47
48 bb3: ; preds = %bb9, %bb8
49 %tmp4 = load i32, i32* @global, !h !0
50 %tmp5 = icmp eq i32 %tmp4, 0
51 unreachable
52
53 bb6: ; preds = %bb2
54 store i32 %tmp, i32* @global.1, !h !0
55 br i1 undef, label %bb7, label %bb1
56
57 bb7: ; preds = %bb10, %bb6
58 br i1 undef, label %bb10, label %bb8
59
60 bb8: ; preds = %bb7
61 br i1 false, label %bb9, label %bb3
62
63 bb9: ; preds = %bb8
64 call void @widget()
65 br label %bb3
66
67 bb10: ; preds = %bb7
68 store i32 0, i32* @global, !h !0
69 br label %bb7
70 }
71
72 declare void @widget()
73
74 attributes #0 = { align=4 }
75
76 !0 = !{}