Index: include/llvm/Target/TargetMachine.h =================================================================== --- include/llvm/Target/TargetMachine.h +++ include/llvm/Target/TargetMachine.h @@ -259,6 +259,10 @@ /// PEI. If false (virtual-register machines), then callee-save register /// spilling and scavenging are not needed or used. virtual bool usesPhysRegsForPEI() const { return true; } + + virtual bool useIPRA() const { + return false; + } }; /// This class describes a target machine that is implemented with the LLVM Index: lib/CodeGen/TargetPassConfig.cpp =================================================================== --- lib/CodeGen/TargetPassConfig.cpp +++ lib/CodeGen/TargetPassConfig.cpp @@ -47,6 +47,9 @@ using namespace llvm; +cl::opt EnableIPRA("enable-ipra", cl::init(false), cl::Hidden, + cl::desc("Enable interprocedural register allocation " + "to reduce load/store at procedure calls.")); static cl::opt DisablePostRASched("disable-post-ra", cl::Hidden, cl::desc("Disable Post Regalloc Scheduler")); static cl::opt DisableBranchFold("disable-branch-fold", cl::Hidden, @@ -362,6 +365,13 @@ if (StringRef(PrintMachineInstrs.getValue()).equals("")) TM.Options.PrintMachineCode = true; + if (EnableIPRA.getNumOccurrences()) + TM.Options.EnableIPRA = EnableIPRA; + else { + // If not explicitly specified, use target default. + TM.Options.EnableIPRA = TM.useIPRA(); + } + if (TM.Options.EnableIPRA) setRequiresCodeGenSCCOrder(); Index: lib/Target/TargetMachine.cpp =================================================================== --- lib/Target/TargetMachine.cpp +++ lib/Target/TargetMachine.cpp @@ -31,10 +31,6 @@ #include "llvm/Target/TargetSubtargetInfo.h" using namespace llvm; -cl::opt EnableIPRA("enable-ipra", cl::init(false), cl::Hidden, - cl::desc("Enable interprocedural register allocation " - "to reduce load/store at procedure calls.")); - //--------------------------------------------------------------------------- // TargetMachine Class // @@ -45,8 +41,6 @@ : TheTarget(T), DL(DataLayoutString), TargetTriple(TT), TargetCPU(CPU), TargetFS(FS), AsmInfo(nullptr), MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false), DefaultOptions(Options), Options(Options) { - if (EnableIPRA.getNumOccurrences()) - this->Options.EnableIPRA = EnableIPRA; } TargetMachine::~TargetMachine() {