diff options
| author | Max Kazantsev <max.kazantsev@azul.com> | 2018-12-28 06:08:51 +0000 |
|---|---|---|
| committer | Max Kazantsev <max.kazantsev@azul.com> | 2018-12-28 06:08:51 +0000 |
| commit | 80e4b40f3e46e6c824853a0965e505b23293fe58 (patch) | |
| tree | ba22a3998db28bc0e579e64111f5b874f208a89b /llvm/lib/Transforms | |
| parent | f2d9df61c7171f6a91dd65a0d277fbbc5feef05c (diff) | |
| download | bcm5719-llvm-80e4b40f3e46e6c824853a0965e505b23293fe58.tar.gz bcm5719-llvm-80e4b40f3e46e6c824853a0965e505b23293fe58.zip | |
[LoopSimplifyCFG] Delete dead blocks in RPO
Deletion of dead blocks in arbitrary order may lead to failure
of assertion in `DeleteDeadBlock` that requires that we have
deleted all predecessors before we can delete the current block.
We should instead delete them in RPO order.
llvm-svn: 350116
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index 59bc30ee836..1ad2499bbba 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -106,7 +106,7 @@ private: SmallPtrSet<BasicBlock *, 8> LiveLoopBlocks; // The blocks of the original loop that will become unreachable from entry // after the constant folding. - SmallPtrSet<BasicBlock *, 8> DeadLoopBlocks; + SmallVector<BasicBlock *, 8> DeadLoopBlocks; // The exits of the original loop that will still be reachable from entry // after the constant folding. SmallPtrSet<BasicBlock *, 8> LiveExitBlocks; @@ -141,7 +141,7 @@ private: PrintOutVector("Blocks in which we can constant-fold terminator:", FoldCandidates); PrintOutSet("Live blocks from the original loop:", LiveLoopBlocks); - PrintOutSet("Dead blocks from the original loop:", DeadLoopBlocks); + PrintOutVector("Dead blocks from the original loop:", DeadLoopBlocks); PrintOutSet("Live exit blocks:", LiveExitBlocks); PrintOutVector("Dead exit blocks:", DeadExitBlocks); if (!DeleteCurrentLoop) @@ -196,7 +196,7 @@ private: // If a loop block wasn't marked as live so far, then it's dead. if (!LiveLoopBlocks.count(BB)) { - DeadLoopBlocks.insert(BB); + DeadLoopBlocks.push_back(BB); continue; } @@ -385,8 +385,11 @@ private: /// relevant updates to DT and LI. void deleteDeadLoopBlocks() { DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager); - if (MSSAU) - MSSAU->removeBlocks(DeadLoopBlocks); + if (MSSAU) { + SmallPtrSet<BasicBlock *, 8> DeadLoopBlocksSet(DeadLoopBlocks.begin(), + DeadLoopBlocks.end()); + MSSAU->removeBlocks(DeadLoopBlocksSet); + } for (auto *BB : DeadLoopBlocks) { assert(BB != L.getHeader() && "Header of the current loop cannot be dead!"); |

