diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2019-01-24 05:20:29 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2019-01-24 05:20:29 +0000 |
commit | 56515a2c76ff32c451004f8270f2ea59b793ab02 (patch) | |
tree | 2cc89c6585cba55439949289b4f7d47539bde3d5 /llvm/lib/Transforms | |
parent | 11d3314241e056748da065b865ad9bf2496cbf76 (diff) | |
download | bcm5719-llvm-56515a2c76ff32c451004f8270f2ea59b793ab02.tar.gz bcm5719-llvm-56515a2c76ff32c451004f8270f2ea59b793ab02.zip |
[LoopSimplifyCFG] Fix inconsistency in live blocks markup
When we choose whether or not we should mark block as dead, we have an
inconsistent logic in markup of live blocks.
- We take candidate IF its terminator branches on constant AND it is immediately
in current loop;
- We mark successor live IF its terminator doesn't branch by constant OR it branches
by constant and the successor is its always taken block.
What we are missing here is that when the terminator branches on a constant but is
not taken as a candidate because is it not immediately in the current loop, we will
mark only one (always taken) successor as live. Therefore, we do NOT do the actual
folding but may NOT mark one of the successors as live. So the result of markup is
wrong in this case, and we may then hit various asserts.
Thanks Jordan Rupprech for reporting this!
Differential Revision: https://reviews.llvm.org/D57095
Reviewed By: rupprecht
llvm-svn: 352024
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index b0fa4f7e0ef..669faf5aa18 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -207,12 +207,13 @@ private: // folding. Only handle blocks from current loop: branches in child loops // are skipped because if they can be folded, they should be folded during // the processing of child loops. - if (TheOnlySucc && LI.getLoopFor(BB) == &L) + bool TakeFoldCandidate = TheOnlySucc && LI.getLoopFor(BB) == &L; + if (TakeFoldCandidate) FoldCandidates.push_back(BB); // Handle successors. for (BasicBlock *Succ : successors(BB)) - if (!TheOnlySucc || TheOnlySucc == Succ) { + if (!TakeFoldCandidate || TheOnlySucc == Succ) { if (L.contains(Succ)) LiveLoopBlocks.insert(Succ); else |