Skip to content

Commit e618758

Browse files
committed
Force emission of a branch in FastISel.
This is similar to rust-lang#29, but for FastISel. The change ensures that a LLVM `br` always codegens a branch, even if fallthrough is possible. We re-use --yk-no-fallthrough for this. To do so we move its definition into a more generic location. With this, the Lua interpreter runs until stop-gapping with the yk JIT.
1 parent c697a93 commit e618758

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

llvm/lib/CodeGen/CodeGen.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@
1414
#include "llvm-c/Initialization.h"
1515
#include "llvm/InitializePasses.h"
1616
#include "llvm/PassRegistry.h"
17+
#include "llvm/Support/CommandLine.h"
1718

1819
using namespace llvm;
1920

21+
llvm::cl::opt<bool> YkNoFallThrough(
22+
"yk-no-fallthrough", cl::Hidden, cl::init(false),
23+
cl::desc("Always emit a branch even if fallthrough is possible. This "
24+
"is required for the yk JIT, so that the machine IR has the "
25+
"same block structure as the high-level IR"));
26+
2027
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
2128
void llvm::initializeCodeGen(PassRegistry &Registry) {
2229
initializeAtomicExpandPass(Registry);

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
using namespace llvm;
112112
using namespace PatternMatch;
113113

114+
extern cl::opt<bool> YkNoFallThrough;
115+
114116
#define DEBUG_TYPE "isel"
115117

116118
STATISTIC(NumFastIselSuccessIndependent, "Number of insts selected by "
@@ -1576,7 +1578,7 @@ bool FastISel::selectInstruction(const Instruction *I) {
15761578
/// (fall-through) successor, and update the CFG.
15771579
void FastISel::fastEmitBranch(MachineBasicBlock *MSucc,
15781580
const DebugLoc &DbgLoc) {
1579-
if (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1 &&
1581+
if ((!YkNoFallThrough) && (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1) &&
15801582
FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
15811583
// For more accurate line information if this is the only non-debug
15821584
// instruction in the block then emit it, otherwise we have the

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ static cl::opt<unsigned> SwitchPeelThreshold(
135135
"switch statement. A value greater than 100 will void this "
136136
"optimization"));
137137

138-
static cl::opt<bool> YkNoFallThrough(
139-
"yk-no-fallthrough", cl::Hidden, cl::init(false),
140-
cl::desc("Always emit a branch even if fallthrough is possible. This "
141-
"is required for the yk JIT, so that the machine IR has the "
142-
"same block structure as the high-level IR"));
138+
extern cl::opt<bool> YkNoFallThrough;
143139

144140
// Limit the width of DAG chains. This is important in general to prevent
145141
// DAG-based analysis from blowing up. For example, alias analysis and

0 commit comments

Comments
 (0)