[llvm] r323515 - [CallSiteSplitting] Fix infinite loop when recording conditions.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 26 02:36:51 PST 2018
Author: fhahn
Date: Fri Jan 26 02:36:50 2018
New Revision: 323515
URL: http://llvm.org/viewvc/llvm-project?rev=323515&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
llvm/trunk/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll
Modified: llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp?rev=323515&r1=323514&r2=323515&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp Fri Jan 26 02:36:50 2018
@@ -140,10 +140,11 @@ static void recordConditions(CallSite CS
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;
}
}
Modified: llvm/trunk/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll?rev=323515&r1=323514&r2=323515&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll (original)
+++ llvm/trunk/test/Transforms/CallSiteSplitting/callsite-no-splitting.ll Fri Jan 26 02:36:50 2018
@@ -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
+}
More information about the llvm-commits
mailing list