Added support for LTO options: sample_profile, new_pass_manager and debug_pass_manager

Differential Revision: https://reviews.llvm.org/D45275

llvm-svn: 329598
This commit is contained in:
Rumeet Dhindsa
2018-04-09 17:56:07 +00:00
parent 695fc9c7fe
commit 682a417e51
6 changed files with 62 additions and 0 deletions

View File

@@ -85,6 +85,7 @@ struct Configuration {
llvm::StringRef Init;
llvm::StringRef LTOAAPipeline;
llvm::StringRef LTONewPmPasses;
llvm::StringRef LTOSampleProfile;
llvm::StringRef MapFile;
llvm::StringRef OutputFile;
llvm::StringRef OptRemarksFilename;
@@ -131,6 +132,8 @@ struct Configuration {
bool ICF;
bool IgnoreDataAddressEquality;
bool IgnoreFunctionAddressEquality;
bool LTODebugPassManager;
bool LTONewPassManager;
bool MergeArmExidx;
bool MipsN32Abi = false;
bool NoinhibitExec;

View File

@@ -657,9 +657,12 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Args.hasArg(OPT_ignore_function_address_equality);
Config->Init = Args.getLastArgValue(OPT_init, "_init");
Config->LTOAAPipeline = Args.getLastArgValue(OPT_lto_aa_pipeline);
Config->LTODebugPassManager = Args.hasArg(OPT_lto_debug_pass_manager);
Config->LTONewPassManager = Args.hasArg(OPT_lto_new_pass_manager);
Config->LTONewPmPasses = Args.getLastArgValue(OPT_lto_newpm_passes);
Config->LTOO = args::getInteger(Args, OPT_lto_O, 2);
Config->LTOPartitions = args::getInteger(Args, OPT_lto_partitions, 1);
Config->LTOSampleProfile = Args.getLastArgValue(OPT_lto_sample_profile);
Config->MapFile = Args.getLastArgValue(OPT_Map);
Config->MergeArmExidx =
Args.hasFlag(OPT_merge_exidx_entries, OPT_no_merge_exidx_entries, true);
@@ -734,6 +737,12 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->ThinLTOJobs = parseInt(S.substr(5), Arg);
else if (S.startswith("mcpu="))
parseClangOption(Saver.save("-" + S), Arg->getSpelling());
else if (S == "new-pass-manager")
Config->LTONewPassManager = true;
else if (S == "debug-pass-manager")
Config->LTODebugPassManager = true;
else if (S.startswith("sample-profile="))
Config->LTOSampleProfile = S.substr(strlen("sample-profile="));
else if (!S.startswith("/") && !S.startswith("-fresolution=") &&
!S.startswith("-pass-through=") && !S.startswith("thinlto"))
parseClangOption(S, Arg->getSpelling());

View File

@@ -104,6 +104,11 @@ static std::unique_ptr<lto::LTO> createLTO() {
lto::ThinBackend Backend;
if (Config->ThinLTOJobs != -1u)
Backend = lto::createInProcessThinBackend(Config->ThinLTOJobs);
Conf.SampleProfile = Config->LTOSampleProfile;
Conf.UseNewPM = Config->LTONewPassManager;
Conf.DebugPassManager = Config->LTODebugPassManager;
return llvm::make_unique<lto::LTO>(std::move(Conf), Backend,
Config->LTOPartitions);
}

View File

@@ -394,10 +394,16 @@ def start_group_paren: Flag<["-"], "(">;
// LTO-related options.
def lto_aa_pipeline: J<"lto-aa-pipeline=">,
HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">;
def lto_debug_pass_manager: F<"lto-debug-pass-manager">,
HelpText<"Debug new pass manager">;
def lto_new_pass_manager: F<"lto-new-pass-manager">,
HelpText<"Use new pass manager">;
def lto_newpm_passes: J<"lto-newpm-passes=">,
HelpText<"Passes to run during LTO">;
def lto_partitions: J<"lto-partitions=">,
HelpText<"Number of LTO codegen partitions">;
def lto_sample_profile: J<"lto-sample-profile=">,
HelpText<"Sample profile file path">;
def disable_verify: F<"disable-verify">;
defm mllvm: Eq<"mllvm">;
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,

View File

@@ -0,0 +1,14 @@
; REQUIRES: x86
; RUN: opt -module-summary %s -o %t.o
; Test new-pass-manager and debug-pass-manager option
; RUN: ld.lld --plugin-opt=new-pass-manager --plugin-opt=debug-pass-manager -o %t2.o %t.o 2>&1 | FileCheck %s
; RUN: ld.lld --plugin-opt=new-pass-manager --lto-debug-pass-manager -o %t2.o %t.o 2>&1 | FileCheck %s
; RUN: ld.lld --lto-new-pass-manager --plugin-opt=debug-pass-manager -o %t2.o %t.o 2>&1 | FileCheck %s
; RUN: ld.lld --lto-new-pass-manager --lto-debug-pass-manager -o %t2.o %t.o 2>&1 | FileCheck %s
; CHECK: Starting llvm::Module pass manager run
; CHECK: Finished llvm::Module pass manager run
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

View File

@@ -0,0 +1,25 @@
; REQUIRES: x86
; RUN: opt -module-summary %s -o %t1.o
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
; RUN: rm -f %t1.lto.o %t2.lto.o
; RUN: ld.lld --lto-sample-profile=/dev/null %t1.o %t2.o -o %t3
; RUN opt -S %t3.lto.o | FileCheck %s
; RUN: rm -f %t1.lto.o %t2.lto.o
; RUN: ld.lld --plugin-opt=sample-profile=/dev/null %t1.o %t2.o -o %t3
; RUN opt -S %t3.lto.o | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK: ProfileSummary
declare void @g(...)
declare void @h(...)
define void @f() {
entry:
call void (...) @g()
call void (...) @h()
ret void
}