As title, this patch fixes hang (https://bugs.llvm.org/show_bug.cgi?id=44611) which caused by unreachable cycles inside cfg when build with jump-threading-across-loop-headers.
TestPlan: check-llvm
Differential D75977
[JumpThreading] Fix PR44611 junparser on Mar 11 2020, 1:58 AM. Authored by
Details As title, this patch fixes hang (https://bugs.llvm.org/show_bug.cgi?id=44611) which caused by unreachable cycles inside cfg when build with jump-threading-across-loop-headers. TestPlan: check-llvm
Diff Detail Event TimelineComment Actions Hi junparser, your main change in JumpThreading.cpp looks good. Now, could you explain your change in removed-use.ll? To be honest, I haven't understood the original intent of the testcase. Thanks!
Comment Actions It's just that the testcase need to be updated after this patch, I just make some simplification since bb3 -> bb4 -> bb5 is an unreachable cycle and we do not need to handle them.
Comment Actions Sorry, the infinite recursion seems to come from EvaluateOnPredecessorEdge, a function that I recently added to support jump threading across two basic blocks. EvaluateOnPredecessorEdge does not have a guard against infinite recursion while its close cousin ComputeValueKnownInPredecessors does. The best thing to do is to get rid of the code duplication I introduced, namely EvaluateOnPredecessorEdge, but for now we can detect infinite recursion by maintaining RecursionSet much like ComputeValueKnownInPredecessors. Alternatively, we could pass a recursion depth and stop recursion when we reach a certain limit. We have a limit on the number of LLVM IR statements we duplicate, so we could use that as a starting point. Anyway, let me try to come up with something. |
We've been trying to avoid calling getDomTree() in JumpThreading where possible because there's a performance cost: it actually flushes all the pending DomTree updates. Calling it for every basic block will likely cause performance issues. (You should be able to find some discussion of this in the review threads for the related JumpThreading patches.)