llvm.org GIT mirror llvm / 9c28201
fix more AST updating bugs, correcting miscompilation in PR8041 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112878 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 51 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
582582 // Update CurAST for NewPHIs if I had pointer type.
583583 if (I.getType()->isPointerTy())
584584 for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
585 CurAST->copyValue(NewPHIs[i], &I);
585 CurAST->copyValue(&I, NewPHIs[i]);
586586
587587 // Finally, remove the instruction from CurAST. It is no longer in the loop.
588588 CurAST->deleteValue(&I);
842842 // inserting PHI nodes as necessary.
843843 for (unsigned i = 0, e = LiveInLoads.size(); i != e; ++i) {
844844 LoadInst *ALoad = LiveInLoads[i];
845 ALoad->replaceAllUsesWith(SSA.GetValueInMiddleOfBlock(ALoad->getParent()));
845 Value *NewVal = SSA.GetValueInMiddleOfBlock(ALoad->getParent());
846 ALoad->replaceAllUsesWith(NewVal);
847 CurAST->copyValue(ALoad, NewVal);
846848 }
847849
848850 // Now that everything is rewritten, delete the old instructions from the body
7070 ret void
7171 }
7272
73 ; PR8041
74 define void @test4(i8* %x, i8 %n) {
75 ; CHECK: @test4
76 %handle1 = alloca i8*
77 %handle2 = alloca i8*
78 store i8* %x, i8** %handle1
79 br label %loop
80
81 loop:
82 %tmp = getelementptr i8* %x, i64 8
83 store i8* %tmp, i8** %handle2
84 br label %subloop
85
86 subloop:
87 %count = phi i8 [ 0, %loop ], [ %nextcount, %subloop ]
88 %offsetx2 = load i8** %handle2
89 store i8 %n, i8* %offsetx2
90 %newoffsetx2 = getelementptr i8* %offsetx2, i64 -1
91 store i8* %newoffsetx2, i8** %handle2
92 %nextcount = add i8 %count, 1
93 %innerexitcond = icmp sge i8 %nextcount, 8
94 br i1 %innerexitcond, label %innerexit, label %subloop
95
96 ; Should have promoted 'handle2' accesses.
97 ; CHECK: subloop:
98 ; CHECK-NEXT: phi i8* [
99 ; CHECK-NEXT: %count = phi i8 [
100 ; CHECK-NEXT: store i8 %n
101 ; CHECK-NOT: store
102 ; CHECK: br i1
103
104 innerexit:
105 %offsetx1 = load i8** %handle1
106 %val = load i8* %offsetx1
107 %cond = icmp eq i8 %val, %n
108 br i1 %cond, label %exit, label %loop
109
110 ; Should not have promoted offsetx1 loads.
111 ; CHECK: innerexit:
112 ; CHECK: %val = load i8* %offsetx1
113 ; CHECK: %cond = icmp eq i8 %val, %n
114 ; CHECK: br i1 %cond, label %exit, label %loop
115
116 exit:
117 ret void
118 }
119