Skip to content

Commit

Permalink
In SelectionDAG lowering, always emit a branch.
Browse files Browse the repository at this point in the history
Even if fallthrough is possible.
  • Loading branch information
vext01 committed Mar 29, 2022
1 parent 4c38c71 commit 9ec5475
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ static cl::opt<unsigned> SwitchPeelThreshold(
"switch statement. A value greater than 100 will void this "
"optimization"));

static cl::opt<bool> 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
Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit 9ec5475

Please sign in to comment.