mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Pass sample pgo flags to thinlto.
Summary: ThinLTO needs to invoke SampleProfileLoader pass during link time in order to annotate profile correctly after module importing. Reviewers: davidxl, mehdi_amini, tejohnson Subscribers: pcc, davide, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27790 llvm-svn: 289957
This commit is contained in:
parent
4441124e06
commit
c09e6935e0
@ -65,6 +65,9 @@ struct Config {
|
||||
/// with this triple.
|
||||
std::string DefaultTriple;
|
||||
|
||||
/// Sample PGO profile path.
|
||||
std::string SampleProfile;
|
||||
|
||||
bool ShouldDiscardValueNames = true;
|
||||
DiagnosticHandlerFunction DiagHandler;
|
||||
|
||||
|
@ -129,6 +129,12 @@ static void computeCacheKey(
|
||||
ArrayRef<uint8_t>((const uint8_t *)&Linkage, sizeof(Linkage)));
|
||||
}
|
||||
|
||||
if (!Conf.SampleProfile.empty()) {
|
||||
auto FileOrErr = MemoryBuffer::getFile(Conf.SampleProfile);
|
||||
if (FileOrErr)
|
||||
Hasher.update(FileOrErr.get()->getBuffer());
|
||||
}
|
||||
|
||||
Key = toHex(Hasher.result());
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,7 @@ static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM,
|
||||
PMB.LoopVectorize = true;
|
||||
PMB.SLPVectorize = true;
|
||||
PMB.OptLevel = Conf.OptLevel;
|
||||
PMB.PGOSampleUse = Conf.SampleProfile;
|
||||
if (IsThinLTO)
|
||||
PMB.populateThinLTOPassManager(passes);
|
||||
else
|
||||
|
2
test/tools/gold/X86/Inputs/afdo.prof
Normal file
2
test/tools/gold/X86/Inputs/afdo.prof
Normal file
@ -0,0 +1,2 @@
|
||||
f:100:3
|
||||
1: 100
|
25
test/tools/gold/X86/thinlto_afdo.ll
Normal file
25
test/tools/gold/X86/thinlto_afdo.ll
Normal file
@ -0,0 +1,25 @@
|
||||
; Generate summary sections
|
||||
; RUN: opt -module-summary %s -o %t1.o
|
||||
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
|
||||
|
||||
; RUN: rm -f %t1.o.4.opt.bc
|
||||
; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
|
||||
; RUN: --plugin-opt=thinlto \
|
||||
; RUN: --plugin-opt=save-temps \
|
||||
; RUN: --plugin-opt=sample-profile=%p/Inputs/afdo.prof \
|
||||
; RUN: --plugin-opt=jobs=1 \
|
||||
; RUN: -shared %t1.o %t2.o -o %t3
|
||||
; RUN: opt -S %t1.o.4.opt.bc | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
; CHECK: ProfileSummary
|
||||
declare void @g(...)
|
||||
declare void @h(...)
|
||||
|
||||
define void @f() {
|
||||
entry:
|
||||
call void (...) @g()
|
||||
call void (...) @h()
|
||||
ret void
|
||||
}
|
@ -171,6 +171,8 @@ namespace options {
|
||||
// Note: This array will contain all plugin options which are not claimed
|
||||
// as plugin exclusive to pass to the code generator.
|
||||
static std::vector<const char *> extra;
|
||||
// Sample profile file path
|
||||
static std::string sample_profile;
|
||||
|
||||
static void process_plugin_option(const char *opt_)
|
||||
{
|
||||
@ -220,6 +222,8 @@ namespace options {
|
||||
message(LDPL_FATAL, "Invalid codegen partition level: %s", opt_ + 5);
|
||||
} else if (opt == "disable-verify") {
|
||||
DisableVerify = true;
|
||||
} else if (opt.startswith("sample-profile=")) {
|
||||
sample_profile= opt.substr(strlen("sample-profile="));
|
||||
} else {
|
||||
// Save this option to pass to the code generator.
|
||||
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
|
||||
@ -728,6 +732,9 @@ static std::unique_ptr<LTO> createLTO() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!options::sample_profile.empty())
|
||||
Conf.SampleProfile = options::sample_profile;
|
||||
|
||||
return llvm::make_unique<LTO>(std::move(Conf), Backend,
|
||||
options::ParallelCodeGenParallelismLevel);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user