aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index f433c4b..8928dc8 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1109,6 +1109,17 @@ bool MachineBasicBlock::canSplitCriticalEdge(
if (Succ->isEHPad())
return false;
+ // Splitting the critical edge to a callbr's indirect block isn't advised.
+ // Don't do it in this generic function.
+ if (Succ->hasAddressTaken())
+ if (auto *cbr = dyn_cast<CallBrInst>(getBasicBlock()->getTerminator()))
+ if (auto *bb = Succ->getBasicBlock())
+ if (cbr->getDefaultDest() != bb)
+ if (llvm::any_of(cbr->getIndirectDests(), [&](const BasicBlock *succ){
+ return succ == bb;
+ }))
+ return false;
+
const MachineFunction *MF = getParent();
// Performance might be harmed on HW that implements branching using exec mask