1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Add a -regalloc=default option that chooses a register allocator based on the -O

optimization level.

This only really affects llc for now because both the llvm-gcc and clang front
ends override the default register allocator. I intend to remove that code later.

llvm-svn: 104904
This commit is contained in:
Jakob Stoklund Olesen 2010-05-27 23:57:25 +00:00
parent 9f9fed5a7c
commit d76041cf58
7 changed files with 28 additions and 13 deletions

View File

@ -85,9 +85,10 @@ namespace llvm {
///
FunctionPass *createDeadMachineInstructionElimPass();
/// Creates a register allocator as the user specified on the command line.
/// Creates a register allocator as the user specified on the command line, or
/// picks one that matches OptLevel.
///
FunctionPass *createRegisterAllocator();
FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
/// LocalRegisterAllocation Pass - This pass register allocates the input code
/// a basic block at a time, yielding code better than the simple register

View File

@ -358,7 +358,7 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
/* allowDoubleDefs= */ true);
// Perform register allocation.
PM.add(createRegisterAllocator());
PM.add(createRegisterAllocator(OptLevel));
printAndVerify(PM, "After Register Allocation");
// Perform stack slot coloring and post-ra machine LICM.

View File

@ -24,6 +24,11 @@ using namespace llvm;
//===---------------------------------------------------------------------===//
MachinePassRegistry RegisterRegAlloc::Registry;
static FunctionPass *createDefaultRegisterAllocator() { return 0; }
static RegisterRegAlloc
defaultRegAlloc("default",
"pick register allocator based on -O option",
createDefaultRegisterAllocator);
//===---------------------------------------------------------------------===//
///
@ -33,8 +38,8 @@ MachinePassRegistry RegisterRegAlloc::Registry;
static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
RegisterPassParser<RegisterRegAlloc> >
RegAlloc("regalloc",
cl::init(&createLinearScanRegisterAllocator),
cl::desc("Register allocator to use (default=linearscan)"));
cl::init(&createDefaultRegisterAllocator),
cl::desc("Register allocator to use"));
//===---------------------------------------------------------------------===//
@ -42,13 +47,22 @@ RegAlloc("regalloc",
/// createRegisterAllocator - choose the appropriate register allocator.
///
//===---------------------------------------------------------------------===//
FunctionPass *llvm::createRegisterAllocator() {
FunctionPass *llvm::createRegisterAllocator(CodeGenOpt::Level OptLevel) {
RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
if (!Ctor) {
Ctor = RegAlloc;
RegisterRegAlloc::setDefault(RegAlloc);
}
return Ctor();
if (Ctor != createDefaultRegisterAllocator)
return Ctor();
// When the 'default' allocator is requested, pick one based on OptLevel.
switch (OptLevel) {
case CodeGenOpt::None:
return createLocalRegisterAllocator();
default:
return createLinearScanRegisterAllocator();
}
}

View File

@ -1,4 +1,4 @@
; RUN: llc < %s -march=arm -mattr=+neon -O0
; RUN: llc < %s -march=arm -mattr=+neon -O0 -regalloc=linearscan
; This test would crash the rewriter when trying to handle a spill after one of
; the @llvm.arm.neon.vld3.v8i8 defined three parts of a register.

View File

@ -1,4 +1,4 @@
; RUN: llc < %s -march=x86 -O0 -fast-isel=false | grep mov | count 5
; RUN: llc < %s -march=x86 -O0 -fast-isel=false -regalloc=linearscan | grep mov | count 5
; PR2343
%llvm.dbg.anchor.type = type { i32, i32 }

View File

@ -1,4 +1,4 @@
; RUN: llc < %s -O0 -march=x86-64 -mattr=+mmx | FileCheck %s
; RUN: llc < %s -O0 -regalloc=linearscan -march=x86-64 -mattr=+mmx | FileCheck %s
; PR4684
target datalayout =

View File

@ -1,4 +1,4 @@
; RUN: llc < %s -mtriple=i386-apple-darwin9 -O0 | grep {movl %edx, 12(%esp)} | count 2
; RUN: llc < %s -mtriple=i386-apple-darwin9 -O0 -regalloc=linearscan | grep {movl %edx, 12(%esp)} | count 2
; rdar://6992609
target triple = "i386-apple-darwin9.0"