Skip to content

Commit

Permalink
Merge rust-lang#30
Browse files Browse the repository at this point in the history
30: Force emission of a branch in FastISel. r=ltratt a=vext01



Co-authored-by: Edd Barrett <vext01@gmail.com>
  • Loading branch information
bors[bot] and vext01 authored Mar 31, 2022
2 parents c697a93 + e618758 commit f6ff7b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 7 additions & 0 deletions llvm/lib/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
#include "llvm-c/Initialization.h"
#include "llvm/InitializePasses.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/CommandLine.h"

using namespace llvm;

llvm::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"));

/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeAtomicExpandPass(Registry);
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
using namespace llvm;
using namespace PatternMatch;

extern cl::opt<bool> YkNoFallThrough;

#define DEBUG_TYPE "isel"

STATISTIC(NumFastIselSuccessIndependent, "Number of insts selected by "
Expand Down Expand Up @@ -1576,7 +1578,7 @@ bool FastISel::selectInstruction(const Instruction *I) {
/// (fall-through) successor, and update the CFG.
void FastISel::fastEmitBranch(MachineBasicBlock *MSucc,
const DebugLoc &DbgLoc) {
if (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1 &&
if ((!YkNoFallThrough) && (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1) &&
FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
// For more accurate line information if this is the only non-debug
// instruction in the block then emit it, otherwise we have the
Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ 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"));
extern cl::opt<bool> YkNoFallThrough;

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

0 comments on commit f6ff7b1

Please sign in to comment.