Skip to content
Snippets Groups Projects
Commit 01e065de authored by Davide Italiano's avatar Davide Italiano
Browse files

[PM] Add support for instrumented PGO in the new pass manager (clang-side)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294961 91177308-0d34-0410-b5e6-96231b3b80d8
parent af74e886
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,9 @@ using namespace llvm;
namespace {
// Default filename used for profile generation.
static constexpr StringLiteral DefaultProfileGenName = "default_%m.profraw";
class EmitAssemblyHelper {
DiagnosticsEngine &Diags;
const HeaderSearchOptions &HSOpts;
......@@ -448,7 +451,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
if (!CodeGenOpts.InstrProfileOutput.empty())
PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
else
PMBuilder.PGOInstrGen = "default_%m.profraw";
PMBuilder.PGOInstrGen = DefaultProfileGenName;
}
if (CodeGenOpts.hasProfileIRUse())
PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
......@@ -775,7 +778,24 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
return;
TheModule->setDataLayout(TM->createDataLayout());
PassBuilder PB(TM.get());
PGOOptions PGOOpt;
// -fprofile-generate.
PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr();
if (PGOOpt.RunProfileGen)
PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
// -fprofile-use.
if (CodeGenOpts.hasProfileIRUse())
PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
// Only pass a PGO options struct if -fprofile-generate or
// -fprofile-use were passed on the cmdline.
PassBuilder PB(TM.get(),
(PGOOpt.RunProfileGen ||
!PGOOpt.ProfileUseFile.empty()) ?
Optional<PGOOptions>(PGOOpt) : None);
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment