aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorAnshil Gandhi <gandhi21299@gmail.com>2023-01-17 14:34:27 -0700
committerAnshil Gandhi <Anshil.Gandhi@amd.com>2023-01-17 17:12:08 -0700
commit5073a622a785e8fd542fd15484970a435ef2e3e5 (patch)
tree6b23d2ae30c5f79d926054f8d78e231dc8c4e5d8 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parentc43f38ec63641a68c36e6f782f14b77543f0a8d8 (diff)
downloadllvm-5073a622a785e8fd542fd15484970a435ef2e3e5.zip
llvm-5073a622a785e8fd542fd15484970a435ef2e3e5.tar.gz
llvm-5073a622a785e8fd542fd15484970a435ef2e3e5.tar.bz2
[MachineBasicBlock] Explicit FT branching param
Introduce a parameter in getFallThrough() to optionally allow returning the fall through basic block in spite of an explicit branch instruction to it. This parameter is set to false by default. Introduce getLogicalFallThrough() which calls getFallThrough(false) to obtain the block while avoiding insertion of a jump instruction to its immediate successor. This patch also reverts the changes made by D134557 and solves the case where a jump is inserted after another jump (branch-relax-no-terminators.mir). Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D140790
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 499ff24..5ef377f 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -944,7 +944,7 @@ const MachineBasicBlock *MachineBasicBlock::getSingleSuccessor() const {
return Successors.size() == 1 ? Successors[0] : nullptr;
}
-MachineBasicBlock *MachineBasicBlock::getFallThrough() {
+MachineBasicBlock *MachineBasicBlock::getFallThrough(bool JumpToFallThrough) {
MachineFunction::iterator Fallthrough = getIterator();
++Fallthrough;
// If FallthroughBlock is off the end of the function, it can't fall through.
@@ -975,8 +975,8 @@ MachineBasicBlock *MachineBasicBlock::getFallThrough() {
// If there is some explicit branch to the fallthrough block, it can obviously
// reach, even though the branch should get folded to fall through implicitly.
- if (MachineFunction::iterator(TBB) == Fallthrough ||
- MachineFunction::iterator(FBB) == Fallthrough)
+ if (!JumpToFallThrough && (MachineFunction::iterator(TBB) == Fallthrough ||
+ MachineFunction::iterator(FBB) == Fallthrough))
return &*Fallthrough;
// If it's an unconditional branch to some block not the fall through, it