diff options
author | Vedant Kumar <vsk@apple.com> | 2020-10-06 14:18:20 -0700 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-10-27 10:12:59 -0700 |
commit | 5a3ef55a524bf9e072d98286e5febdb218b1fc72 (patch) | |
tree | 0fd9636331470a852d8dfe955a36c69a6cc781a0 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 1a1aad9156407bc891e2738e9877c03bd594e67f (diff) | |
download | llvm-5a3ef55a524bf9e072d98286e5febdb218b1fc72.zip llvm-5a3ef55a524bf9e072d98286e5febdb218b1fc72.tar.gz llvm-5a3ef55a524bf9e072d98286e5febdb218b1fc72.tar.bz2 |
[Utils] Skip RemoveRedundantDbgInstrs in MergeBlockIntoPredecessor (PR47746)
This patch changes MergeBlockIntoPredecessor to skip the call to
RemoveRedundantDbgInstrs, in effect partially reverting D71480 due to
some compile-time issues spotted in LoopUnroll and SimplifyCFG.
The call to RemoveRedundantDbgInstrs appears to have changed the
worst-case behavior of the merging utility. Loosely speaking, it seems
to have gone from O(#phis) to O(#insts).
It might not be possible to mitigate this by scanning a block to
determine whether there are any debug intrinsics to remove, since such a
scan costs O(#insts).
So: skip the call to RemoveRedundantDbgInstrs. There's surprisingly
little fallout from this, and most of it can be addressed by doing
RemoveRedundantDbgInstrs later. The exception is (the block-local
version of) SimplifyCFG, where it might just be too expensive to call
RemoveRedundantDbgInstrs.
Differential Revision: https://reviews.llvm.org/D88928
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 45feeae..06ed37c 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -655,6 +655,7 @@ bool CodeGenPrepare::eliminateFallThrough(Function &F) { for (auto &Block : llvm::make_range(std::next(F.begin()), F.end())) Blocks.push_back(&Block); + SmallSet<WeakTrackingVH, 16> Preds; for (auto &Block : Blocks) { auto *BB = cast_or_null<BasicBlock>(Block); if (!BB) @@ -673,8 +674,16 @@ bool CodeGenPrepare::eliminateFallThrough(Function &F) { // Merge BB into SinglePred and delete it. MergeBlockIntoPredecessor(BB); + Preds.insert(SinglePred); } } + + // (Repeatedly) merging blocks into their predecessors can create redundant + // debug intrinsics. + for (auto &Pred : Preds) + if (auto *BB = cast_or_null<BasicBlock>(Pred)) + RemoveRedundantDbgInstrs(BB); + return Changed; } |