aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 57106e4..1750719 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -124,15 +124,25 @@ namespace clang {
extern llvm::cl::opt<bool> ClSanitizeGuardChecks;
}
-namespace {
-
// Default filename used for profile generation.
-std::string getDefaultProfileGenName() {
+static std::string getDefaultProfileGenName() {
return DebugInfoCorrelate || ProfileCorrelate != InstrProfCorrelator::NONE
? "default_%m.proflite"
: "default_%m.profraw";
}
+// Path and name of file used for profile generation
+static std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+ std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+ if (CodeGenOpts.ContinuousProfileSync)
+ FileName = "%c" + FileName;
+ return FileName;
+}
+
+namespace {
+
class EmitAssemblyHelper {
CompilerInstance &CI;
DiagnosticsEngine &Diags;
@@ -551,7 +561,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
return std::nullopt;
InstrProfOptions Options;
Options.NoRedZone = CodeGenOpts.DisableRedZone;
- Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+ Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+ ? ("%c" + CodeGenOpts.InstrProfileOutput)
+ : CodeGenOpts.InstrProfileOutput;
Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
return Options;
}
@@ -822,13 +834,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (CodeGenOpts.hasProfileIRInstr())
// -fprofile-generate.
- PGOOpt = PGOOptions(
- CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
- : CodeGenOpts.InstrProfileOutput,
- "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- PGOOptions::NoCSAction, ClPGOColdFuncAttr,
- CodeGenOpts.DebugInfoForProfiling,
- /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
+ PGOOpt = PGOOptions(getProfileGenName(CodeGenOpts), "", "",
+ CodeGenOpts.MemoryProfileUsePath, nullptr,
+ PGOOptions::IRInstr, PGOOptions::NoCSAction,
+ ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling,
+ /*PseudoProbeForProfiling=*/false,
+ CodeGenOpts.AtomicProfileUpdate);
else if (CodeGenOpts.hasProfileIRUse()) {
// -fprofile-use.
auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
@@ -872,18 +883,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
PGOOpt->Action != PGOOptions::SampleUse &&
"Cannot run CSProfileGen pass with ProfileGen or SampleUse "
" pass");
- PGOOpt->CSProfileGenFile = CodeGenOpts.InstrProfileOutput.empty()
- ? getDefaultProfileGenName()
- : CodeGenOpts.InstrProfileOutput;
+ PGOOpt->CSProfileGenFile = getProfileGenName(CodeGenOpts);
PGOOpt->CSAction = PGOOptions::CSIRInstr;
} else
- PGOOpt = PGOOptions("",
- CodeGenOpts.InstrProfileOutput.empty()
- ? getDefaultProfileGenName()
- : CodeGenOpts.InstrProfileOutput,
- "", /*MemoryProfile=*/"", nullptr,
- PGOOptions::NoAction, PGOOptions::CSIRInstr,
- ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
+ PGOOpt = PGOOptions("", getProfileGenName(CodeGenOpts), "",
+ /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction,
+ PGOOptions::CSIRInstr, ClPGOColdFuncAttr,
+ CodeGenOpts.DebugInfoForProfiling);
}
if (TM)
TM->setPGOOption(PGOOpt);