diff options
author | Guozhi Wei <carrot@google.com> | 2023-06-21 18:54:31 +0000 |
---|---|---|
committer | Guozhi Wei <carrot@google.com> | 2023-06-21 18:54:31 +0000 |
commit | 1bcb6a3da231ee3bcf8513880599b5d054f590a4 (patch) | |
tree | ed54b3b52921ef3a047fb66059fbb14a3031bb2b /llvm/lib/CodeGen/MachineBlockPlacement.cpp | |
parent | c172210492f04664b5e2787df7257eb61c76cc4c (diff) | |
download | llvm-1bcb6a3da231ee3bcf8513880599b5d054f590a4.zip llvm-1bcb6a3da231ee3bcf8513880599b5d054f590a4.tar.gz llvm-1bcb6a3da231ee3bcf8513880599b5d054f590a4.tar.bz2 |
[MBP] Enable duplicating return block to remove jump to return
Sometimes LLVM generates branch to return instruction, like PR63227.
It is because in function MachineBlockPlacement::canTailDuplicateUnplacedPreds
we avoid duplicating a BB into another already placed BB to prevent destroying
computed layout. But if the successor BB is a return block, duplicating it will
only reduce taken branches without hurt to any other branches.
Differential Revision: https://reviews.llvm.org/D153093
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index eec6022..912e9ec 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -1159,7 +1159,7 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds( // tail-duplicated into. // Skip any blocks that are already placed or not in this loop. if (Pred == BB || (BlockFilter && !BlockFilter->count(Pred)) - || BlockToChain[Pred] == &Chain) + || (BlockToChain[Pred] == &Chain && !Succ->succ_empty())) continue; if (!TailDup.canTailDuplicate(Succ, Pred)) { if (Successors.size() > 1 && hasSameSuccessors(*Pred, Successors)) |