r309282 - Make new PM honor -fdebug-info-for-profiling (clang side)
Dehao Chen via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 27 08:29:53 PDT 2017
Author: dehao
Date: Thu Jul 27 08:29:53 2017
New Revision: 309282
URL: http://llvm.org/viewvc/llvm-project?rev=309282&view=rev
Log:
Make new PM honor -fdebug-info-for-profiling (clang side)
Summary: The new PM needs to invoke add-discriminator pass when building with -fdebug-info-for-profiling.
Reviewers: chandlerc, davidxl
Reviewed By: chandlerc
Subscribers: sanjoy, cfe-commits
Differential Revision: https://reviews.llvm.org/D35746
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=309282&r1=309281&r2=309282&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 27 08:29:53 2017
@@ -840,28 +840,27 @@ void EmitAssemblyHelper::EmitAssemblyWit
return;
TheModule->setDataLayout(TM->createDataLayout());
- PGOOptions PGOOpt;
+ Optional<PGOOptions> PGOOpt;
- // -fprofile-generate.
- PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr();
- if (PGOOpt.RunProfileGen)
- PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
- DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
+ if (CodeGenOpts.hasProfileIRInstr())
+ // -fprofile-generate.
+ PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty()
+ ? DefaultProfileGenName
+ : CodeGenOpts.InstrProfileOutput,
+ "", "", true, CodeGenOpts.DebugInfoForProfiling);
+ else if (CodeGenOpts.hasProfileIRUse())
+ // -fprofile-use.
+ PGOOpt = PGOOptions("", CodeGenOpts.ProfileInstrumentUsePath, "", false,
+ CodeGenOpts.DebugInfoForProfiling);
+ else if (!CodeGenOpts.SampleProfileFile.empty())
+ // -fprofile-sample-use
+ PGOOpt = PGOOptions("", "", CodeGenOpts.SampleProfileFile, false,
+ CodeGenOpts.DebugInfoForProfiling);
+ else if (CodeGenOpts.DebugInfoForProfiling)
+ // -fdebug-info-for-profiling
+ PGOOpt = PGOOptions("", "", "", false, true);
- // -fprofile-use.
- if (CodeGenOpts.hasProfileIRUse())
- PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
-
- if (!CodeGenOpts.SampleProfileFile.empty())
- PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
-
- // 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() ||
- !PGOOpt.SampleProfileFile.empty()) ?
- Optional<PGOOptions>(PGOOpt) : None);
+ PassBuilder PB(TM.get(), PGOOpt);
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
More information about the cfe-commits
mailing list