From 81da0d45f857dfd10f87be5c60008afdf7f7d02e Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 14 Aug 2017 19:54:47 +0000 Subject: [PATCH] IPRA: Allow target to enable IPRA by default llvm-svn: 310876 --- llvm/include/llvm/Target/TargetMachine.h | 6 ++++++ llvm/lib/CodeGen/TargetPassConfig.cpp | 10 ++++++++++ llvm/lib/Target/TargetMachine.cpp | 6 ------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 14c7a635a7c0..5421b22462ae 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -259,6 +259,12 @@ public: /// PEI. If false (virtual-register machines), then callee-save register /// spilling and scavenging are not needed or used. virtual bool usesPhysRegsForPEI() const { return true; } + + /// True if the target wants to use interprocedural register allocation by + /// default. The -enable-ipra flag can be used to override this. + virtual bool useIPRA() const { + return false; + } }; /// This class describes a target machine that is implemented with the LLVM diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 75a565e898f4..481baea2dff0 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/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 @@ TargetPassConfig::TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm) 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(); diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index b2578fb7a028..3b16dee5a0fa 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/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 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString, : 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() {