diff options
author | Serguei Katkov <serguei.katkov@azul.com> | 2023-08-18 05:26:52 +0000 |
---|---|---|
committer | Serguei Katkov <serguei.katkov@azul.com> | 2023-08-29 04:35:06 +0000 |
commit | a701b7e368b70688bb4b84dafcaa43fa7c9a3649 (patch) | |
tree | cfae2a1d9f87ef4735d88709cac8dfb1c500322c /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 692344d87357ded619d216b265a9375f4326d8fb (diff) | |
download | llvm-a701b7e368b70688bb4b84dafcaa43fa7c9a3649.zip llvm-a701b7e368b70688bb4b84dafcaa43fa7c9a3649.tar.gz llvm-a701b7e368b70688bb4b84dafcaa43fa7c9a3649.tar.bz2 |
[CGP] Remove dead PHI nodes before elimination of mostly empty blocks
Before elimination of mostly empty block it makes sense to remove dead PHI nodes.
It open more opportunity for elimination plus eliminates dead code itself.
It appeared that change results in failing many unit tests and some of
them I've updated and for another one I disable this optimization.
The pattern I observed in the tests is that there is a infinite loop
without side effects. As a result after elimination of dead phi node all other
related instruction are also removed and tests stops to check what it is expected.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D158503
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 194a98e..7fc62f2 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -268,6 +268,11 @@ static cl::opt<unsigned> MaxAddressUsersToScan("cgp-max-address-users-to-scan", cl::init(100), cl::Hidden, cl::desc("Max number of address users to look at")); + +static cl::opt<bool> + DisableDeletePHIs("disable-cgp-delete-phis", cl::Hidden, cl::init(false), + cl::desc("Disable elimination of dead PHI nodes.")); + namespace { enum ExtType { @@ -878,8 +883,12 @@ bool CodeGenPrepare::eliminateMostlyEmptyBlocks(Function &F) { // as we remove them. // Note that this intentionally skips the entry block. SmallVector<WeakTrackingVH, 16> Blocks; - for (auto &Block : llvm::drop_begin(F)) + for (auto &Block : llvm::drop_begin(F)) { + // Delete phi nodes that could block deleting other empty blocks. + if (!DisableDeletePHIs) + MadeChange |= DeleteDeadPHIs(&Block, TLInfo); Blocks.push_back(&Block); + } for (auto &Block : Blocks) { BasicBlock *BB = cast_or_null<BasicBlock>(Block); |