[CallSiteSplitting] Fix infinite loop when recording conditions.

Fix infinite loop when recording conditions by correctly marking basic
blocks as visited.

Fixes https://bugs.llvm.org/show_bug.cgi?id=36105

llvm-svn: 323515
This commit is contained in:
Florian Hahn 2018-01-26 10:36:50 +00:00
parent d2cc6fd90b
commit 212afb9fd9
2 changed files with 26 additions and 1 deletions

View File

@ -140,10 +140,11 @@ static void recordConditions(CallSite CS, BasicBlock *Pred,
recordCondition(CS, Pred, CS.getInstruction()->getParent(), Conditions);
BasicBlock *From = Pred;
BasicBlock *To = Pred;
SmallPtrSet<BasicBlock *, 4> Visited = {From};
SmallPtrSet<BasicBlock *, 4> Visited;
while (!Visited.count(From->getSinglePredecessor()) &&
(From = From->getSinglePredecessor())) {
recordCondition(CS, From, To, Conditions);
Visited.insert(From);
To = From;
}
}

View File

@ -16,3 +16,27 @@ Tail:
%r = call i32 @callee(i32* %a, i32 %v, i32 %p)
ret i32 %r
}
define void @fn1(i16 %p1) {
entry:
ret void
}
define void @fn2() {
ret void
; Unreachable code below
for.inc: ; preds = %for.inc
br i1 undef, label %for.end6, label %for.inc
for.end6: ; preds = %for.inc
br i1 undef, label %lor.rhs, label %lor.end
lor.rhs: ; preds = %for.end6
br label %lor.end
lor.end: ; preds = %for.end6, %lor.rhs
call void @fn1(i16 0)
ret void
}