llvm.org GIT mirror llvm / 61d5bb6
Merge 80768 from mainline. fix PR4815: some cases where DeleteDeadInstruction can delete the instruction BBI points to. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@81029 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
2 changed file(s) with 39 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
8383
8484 bool MadeChange = false;
8585
86 // Do a top-down walk on the BB
86 // Do a top-down walk on the BB.
8787 for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ) {
8888 Instruction *Inst = BBI++;
8989
124124 DeleteDeadInstruction(DepStore);
125125 NumFastStores++;
126126 MadeChange = true;
127
127
128 // DeleteDeadInstruction can delete the current instruction in loop
129 // cases, reset BBI.
130 BBI = Inst;
128131 if (BBI != BB.begin())
129132 --BBI;
130133 continue;
135138 if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) {
136139 if (SI->getPointerOperand() == DepLoad->getPointerOperand() &&
137140 SI->getOperand(0) == DepLoad) {
141 // DeleteDeadInstruction can delete the current instruction. Save BBI
142 // in case we need it.
143 WeakVH NextInst(BBI);
144
138145 DeleteDeadInstruction(SI);
139 if (BBI != BB.begin())
146
147 if (NextInst == 0) // Next instruction deleted.
148 BBI = BB.begin();
149 else if (BBI != BB.begin()) // Revisit this instruction if possible.
140150 --BBI;
141151 NumFastStores++;
142152 MadeChange = true;
0 ; RUN: llvm-as < %s | opt -dse | llvm-dis
1
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
3 target triple = "i386-apple-darwin10.0"
4
5 @g80 = external global i8 ; [#uses=3]
6
7 declare signext i8 @foo(i8 signext, i8 signext) nounwind readnone ssp
8
9 declare i32 @func68(i32) nounwind readonly ssp
10
11 ; PR4815
12 define void @test1(i32 %int32p54) noreturn nounwind ssp {
13 entry:
14 br label %bb
15
16 bb: ; preds = %bb, %entry
17 %storemerge = phi i8 [ %2, %bb ], [ 1, %entry ] ; [#uses=1]
18 store i8 %storemerge, i8* @g80
19 %0 = tail call i32 @func68(i32 1) nounwind ssp ; [#uses=1]
20 %1 = trunc i32 %0 to i8 ; [#uses=1]
21 store i8 %1, i8* @g80, align 1
22 store i8 undef, i8* @g80, align 1
23 %2 = tail call signext i8 @foo(i8 signext undef, i8 signext 1) nounwind ; [#uses=1]
24 br label %bb
25 }