From 9ec5475bb261347f9e1788f187e5ef4d6c77e640 Mon Sep 17 00:00:00 2001 From: Edd Barrett Date: Tue, 29 Mar 2022 15:10:58 +0100 Subject: [PATCH] In SelectionDAG lowering, always emit a branch. Even if fallthrough is possible. --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index bd2ebfd0bd3b9e..69ec0678f0ad58 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -135,6 +135,12 @@ static cl::opt SwitchPeelThreshold( "switch statement. A value greater than 100 will void this " "optimization")); +static cl::opt YkNoFallThrough( + "yk-no-fallthrough", cl::Hidden, cl::init(false), + cl::desc("Always emit a branch even if fallthrough is possible. This " + "is required for the yk JIT, so that the machine IR has the " + "same block structure as the high-level IR")); + // Limit the width of DAG chains. This is important in general to prevent // DAG-based analysis from blowing up. For example, alias analysis and // load clustering may not complete in reasonable time. It is difficult to @@ -2348,7 +2354,8 @@ void SelectionDAGBuilder::visitBr(const BranchInst &I) { // If this is not a fall-through branch or optimizations are switched off, // emit the branch. - if (Succ0MBB != NextBlock(BrMBB) || TM.getOptLevel() == CodeGenOpt::None) + if ((YkNoFallThrough) || (Succ0MBB != NextBlock(BrMBB) || + TM.getOptLevel() == CodeGenOpt::None)) DAG.setRoot(DAG.getNode(ISD::BR, getCurSDLoc(), MVT::Other, getControlRoot(), DAG.getBasicBlock(Succ0MBB)));