llvm.org GIT mirror llvm / 0f17fd2
[MemorySSA] Update last_access_in_block check. The check for "was there an access in this block" should be: is the last access in this block and is it not a newly inserted phi. Resolves new test in PR43438. Also fix a typo when simplifying trivial Phis to match the comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373380 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 1 year, 19 days ago
2 changed file(s) with 61 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
302302
303303 // See if we had a local def, and if not, go hunting.
304304 MemoryAccess *DefBefore = getPreviousDef(MD);
305 bool DefBeforeSameBlock = DefBefore->getBlock() == MD->getBlock();
305 bool DefBeforeSameBlock = false;
306 if (DefBefore->getBlock() == MD->getBlock() &&
307 !(isa(DefBefore) &&
308 std::find(InsertedPHIs.begin(), InsertedPHIs.end(), DefBefore) !=
309 InsertedPHIs.end()))
310 DefBeforeSameBlock = true;
306311
307312 // There is a def before us, which means we can replace any store/phi uses
308313 // of that thing with us, since we are in the way of whatever was there
627632
628633 // If NewMPhi is a trivial phi, remove it. Its use in the header MPhi will be
629634 // replaced with the unique value.
630 tryRemoveTrivialPhi(MPhi);
635 tryRemoveTrivialPhi(NewMPhi);
631636 }
632637
633638 void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks,
4343 ret void
4444 }
4545
46
47 ; CHECK-LABEL: @f()
48 ; CHECK: 8 = MemoryPhi(
49 ; CHECK: 7 = MemoryPhi(
50 ; CHECK: 11 = MemoryPhi(
51 ; CHECK: 10 = MemoryPhi(
52 ; CHECK: 9 = MemoryPhi(
53 define void @f() {
54 entry:
55 %e = alloca i16, align 1
56 br label %lbl1
57
58 lbl1: ; preds = %if.else, %for.end5, %entry
59 store i16 undef, i16* %e, align 1
60 %0 = load i16, i16* %e, align 1
61 %call = call i16 @g(i16 %0)
62 br i1 undef, label %for.end, label %if.else
63
64 for.end: ; preds = %if.then
65 br i1 true, label %for.cond2, label %lbl2
66
67 lbl2: ; preds = %for.body4, %if.end
68 br label %for.cond2
69
70 for.cond2: ; preds = %lbl3
71 br i1 undef, label %for.body4, label %for.end5
72
73 for.body4: ; preds = %for.cond2
74 br label %lbl2
75
76 for.end5: ; preds = %for.cond2
77 switch i32 undef, label %unreachable [
78 i32 0, label %if.end12
79 i32 2, label %lbl1
80 ]
81
82 if.else: ; preds = %lbl1
83 switch i32 undef, label %unreachable [
84 i32 0, label %if.end12
85 i32 2, label %lbl1
86 ]
87
88 if.end12: ; preds = %cleanup.cont11s, %cleanup.cont
89 call void @llvm.lifetime.end.p0i8(i64 1, i8* undef)
90 ret void
91
92 unreachable: ; preds = %if.else, %for.end5
93 unreachable
94 }
95
96 declare i16 @g(i16)
97
98 ; Function Attrs: argmemonly nounwind willreturn
99 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)