mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Fix an infinite loop on 300.twolf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40497 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
02d6852a1c
commit
0d16988690
@ -651,7 +651,8 @@ namespace {
|
||||
SmallVector<Instruction*, 4>& toErase);
|
||||
bool processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase);
|
||||
Value *performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
||||
DenseMap<BasicBlock*, Value*> &Phis);
|
||||
DenseMap<BasicBlock*, Value*> &Phis,
|
||||
SmallPtrSet<BasicBlock*, 4>& visited);
|
||||
void dump(DenseMap<BasicBlock*, Value*>& d);
|
||||
};
|
||||
|
||||
@ -706,7 +707,8 @@ void GVN::dump(DenseMap<BasicBlock*, Value*>& d) {
|
||||
|
||||
|
||||
Value *GVN::performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
||||
DenseMap<BasicBlock*, Value*> &Phis) {
|
||||
DenseMap<BasicBlock*, Value*> &Phis,
|
||||
SmallPtrSet<BasicBlock*, 4>& visited) {
|
||||
DenseMap<BasicBlock*, Value*>::iterator DI = Phis.find(BB);
|
||||
if (DI != Phis.end())
|
||||
return DI->second;
|
||||
@ -719,17 +721,25 @@ Value *GVN::performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
||||
Phis.insert(std::make_pair(BB, DI->second));
|
||||
return DI->second;
|
||||
} else {
|
||||
Value* domV = performPHIConstruction(*pred_begin(BB), orig, Phis);
|
||||
visited.insert(BB);
|
||||
Value* domV = performPHIConstruction(*pred_begin(BB), orig, Phis, visited);
|
||||
visited.erase(BB);
|
||||
|
||||
Phis.insert(std::make_pair(BB, domV));
|
||||
return domV;
|
||||
}
|
||||
} else {
|
||||
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin());
|
||||
PN->reserveOperandSpace(numPreds);
|
||||
|
||||
|
||||
visited.insert(BB);
|
||||
// Fill in the incoming values for the block.
|
||||
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
|
||||
PN->addIncoming(performPHIConstruction(*PI, orig, Phis), *PI);
|
||||
if (!visited.count(*PI))
|
||||
PN->addIncoming(performPHIConstruction(*PI, orig, Phis, visited), *PI);
|
||||
else
|
||||
PN->addIncoming(PN, *PI);
|
||||
visited.erase(BB);
|
||||
|
||||
bool all_same = PN->getNumIncomingValues() != 1;
|
||||
Value* first = PN->getIncomingValue(0);
|
||||
@ -772,7 +782,8 @@ bool GVN::processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase
|
||||
return false;
|
||||
}
|
||||
|
||||
Value* v = performPHIConstruction(L->getParent(), L, repl);
|
||||
SmallPtrSet<BasicBlock*, 4> visited;
|
||||
Value* v = performPHIConstruction(L->getParent(), L, repl, visited);
|
||||
|
||||
MD.removeInstruction(L);
|
||||
L->replaceAllUsesWith(v);
|
||||
|
14
test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
Normal file
14
test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
Normal file
@ -0,0 +1,14 @@
|
||||
; RUN: llvm-as < %s | opt -gvn | llvm-dis
|
||||
|
||||
%struct.INT2 = type { i32, i32 }
|
||||
@blkshifts = external global %struct.INT2* ; <%struct.INT2**> [#uses=2]
|
||||
|
||||
define i32 @xcompact() {
|
||||
entry:
|
||||
store %struct.INT2* null, %struct.INT2** @blkshifts, align 4
|
||||
br label %bb
|
||||
|
||||
bb: ; preds = %bb, %entry
|
||||
%tmp10 = load %struct.INT2** @blkshifts, align 4 ; <%struct.INT2*> [#uses=0]
|
||||
br label %bb
|
||||
}
|
Loading…
Reference in New Issue
Block a user