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)));