diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-01-30 15:25:02 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-01-30 15:25:02 +0000 |
commit | 0ab6eba6b84235523cbb11f4c2a0b98016d1df75 (patch) | |
tree | cdee1c056f59b5f52589f8b77da5fc150d3251d0 | |
parent | 8a0e312d1af7d9556d93264aa3fa963486ab6d11 (diff) |
Merging r323515:
------------------------------------------------------------------------
r323515 | fhahn | 2018-01-26 11:36:50 +0100 (Fri, 26 Jan 2018) | 7 lines
[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
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@323771 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/CallSiteSplitting.cpp | 3 | ||||
-rw-r--r-- | test/Transforms/CallSiteSplitting/callsite-no-splitting.ll | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/CallSiteSplitting.cpp b/lib/Transforms/Scalar/CallSiteSplitting.cpp index caa73b2ff01c..4edea7cc3c82 100644 --- a/lib/Transforms/Scalar/CallSiteSplitting.cpp +++ b/lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -142,10 +142,11 @@ recordConditions(const 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; } } diff --git a/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll b/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll index ca41bd6fc5e1..25b4cb23be60 100644 --- a/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll +++ b/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll @@ -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 +} |