Skip to content

Commit

Permalink
IPRA: Allow target to enable IPRA by default
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310876 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
arsenm committed Aug 14, 2017
1 parent 2e825a5 commit e0ef9f3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions include/llvm/Target/TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ class TargetMachine {
/// 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
Expand Down
10 changes: 10 additions & 0 deletions lib/CodeGen/TargetPassConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

using namespace llvm;

cl::opt<bool> EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
cl::desc("Enable interprocedural register allocation "
"to reduce load/store at procedure calls."));
static cl::opt<bool> DisablePostRASched("disable-post-ra", cl::Hidden,
cl::desc("Disable Post Regalloc Scheduler"));
static cl::opt<bool> DisableBranchFold("disable-branch-fold", cl::Hidden,
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 0 additions & 6 deletions lib/Target/TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#include "llvm/Target/TargetSubtargetInfo.h"
using namespace llvm;

cl::opt<bool> EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
cl::desc("Enable interprocedural register allocation "
"to reduce load/store at procedure calls."));

//---------------------------------------------------------------------------
// TargetMachine Class
//
Expand All @@ -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() {
Expand Down

0 comments on commit e0ef9f3

Please sign in to comment.