[PATCH] D29309: [PM] Add support for instrumented PGO in the new pass manager (clang-side)
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 08:18:42 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294961: [PM] Add support for instrumented PGO in the new pass manager (clang-side) (authored by davide).
Changed prior to commit:
https://reviews.llvm.org/D29309?vs=87713&id=88205#toc
Repository:
rL LLVM
https://reviews.llvm.org/D29309
Files:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -61,6 +61,9 @@
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 @@
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 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29309.88205.patch
Type: text/x-patch
Size: 1654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170213/eef7ffa7/attachment.bin>
More information about the llvm-commits
mailing list