aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorGuozhi Wei <carrot@google.com>2023-06-21 18:54:31 +0000
committerGuozhi Wei <carrot@google.com>2023-06-21 18:54:31 +0000
commit1bcb6a3da231ee3bcf8513880599b5d054f590a4 (patch)
treeed54b3b52921ef3a047fb66059fbb14a3031bb2b /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parentc172210492f04664b5e2787df7257eb61c76cc4c (diff)
downloadllvm-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.cpp2
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))