forked from OSchip/llvm-project
ELF: Add flag for controlling LTO optimization level.
Differential Revision: http://reviews.llvm.org/D18667 llvm-svn: 265053
This commit is contained in:
parent
326014ad99
commit
ed22f9b6f1
|
@ -90,6 +90,7 @@ struct Configuration {
|
|||
ELFKind EKind = ELFNoneKind;
|
||||
uint16_t EMachine = llvm::ELF::EM_NONE;
|
||||
uint64_t EntryAddr = -1;
|
||||
unsigned LtoO = 2;
|
||||
unsigned Optimize = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -282,6 +282,12 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
|||
error("invalid optimization level");
|
||||
}
|
||||
|
||||
if (auto *Arg = Args.getLastArg(OPT_lto_O)) {
|
||||
StringRef Val = Arg->getValue();
|
||||
if (Val.getAsInteger(10, Config->LtoO))
|
||||
error("invalid optimization level");
|
||||
}
|
||||
|
||||
if (auto *Arg = Args.getLastArg(OPT_hash_style)) {
|
||||
StringRef S = Arg->getValue();
|
||||
if (S == "gnu") {
|
||||
|
|
|
@ -62,7 +62,7 @@ static void runLTOPasses(Module &M, TargetMachine &TM) {
|
|||
PMB.VerifyOutput = true;
|
||||
PMB.LoopVectorize = true;
|
||||
PMB.SLPVectorize = true;
|
||||
PMB.OptLevel = 2; // FIXME: This should be an option.
|
||||
PMB.OptLevel = Config->LtoO;
|
||||
PMB.populateLTOPassManager(LtoPasses);
|
||||
LtoPasses.run(M);
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ def init : Separate<["-"], "init">, MetaVarName<"<symbol>">,
|
|||
def l : JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
|
||||
HelpText<"Root name of library to use">;
|
||||
|
||||
def lto_O : Joined<["--"], "lto-O">, MetaVarName<"<opt-level>">,
|
||||
HelpText<"Optimization level for LTO">;
|
||||
|
||||
def m : JoinedOrSeparate<["-"], "m">,
|
||||
HelpText<"Set target emulation">;
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
; RUN: llvm-as -o %t.o %s
|
||||
; RUN: ld.lld -o %t0 -m elf_x86_64 -e main --lto-O0 %t.o
|
||||
; RUN: llvm-nm %t0 | FileCheck --check-prefix=CHECK-O0 %s
|
||||
; RUN: ld.lld -o %t2 -m elf_x86_64 -e main --lto-O2 %t.o
|
||||
; RUN: llvm-nm %t2 | FileCheck --check-prefix=CHECK-O2 %s
|
||||
; RUN: ld.lld -o %t2a -m elf_x86_64 -e main %t.o
|
||||
; RUN: llvm-nm %t2a | FileCheck --check-prefix=CHECK-O2 %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; CHECK-O0: foo
|
||||
; CHECK-O2-NOT: foo
|
||||
define internal void @foo() {
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main() {
|
||||
call void @foo()
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue