diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -33,6 +33,7 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/RemoteBisectorClient.h" #include "llvm/Target/TargetMachine.h" #define DEBUG_TYPE "instruction-select" @@ -48,6 +49,11 @@ static const std::string CoveragePrefix; #endif +cl::opt + BisectISel("gisel-bisect-selection", + cl::desc("Enable remote bisection in GlobalISel after isel"), + cl::init(false)); + char InstructionSelect::ID = 0; INITIALIZE_PASS_BEGIN(InstructionSelect, DEBUG_TYPE, "Select target instructions out of generic instructions", @@ -300,6 +306,26 @@ } } + if (BisectISel) { + RemoteBisectClient BisectClient; + // If we're building with multiple architectures, we could have conflicts + // with using just the module + function name. Add the triple arch to + // disambiguate further. + auto &M = *MF.getFunction().getParent(); + std::string Arch = Triple(M.getTargetTriple()).getArchName().str(); + std::string Key = Arch + " " + + MF.getFunction().getParent()->getSourceFileName() + " " + + MF.getFunction().getName().str(); + if (!BisectClient.shouldPerformBisectAction(Key)) { + MachineOptimizationRemarkMissed R("gisel-bisect", "GISelFailure", + MF.getFunction().getSubprogram(), + &*MF.begin()); + R << "bisection specified fall back"; + reportGISelFailure(MF, TPC, MORE, R); + return false; + } + } + // FIXME: FinalizeISel pass calls finalizeLowering, so it's called twice. auto &TLI = *MF.getSubtarget().getTargetLowering(); TLI.finalizeLowering(MF);