diff options
author | Qiongsi Wu <qwu@ibm.com> | 2023-08-15 09:39:03 -0400 |
---|---|---|
committer | Qiongsi Wu <qwu@ibm.com> | 2023-08-15 10:10:03 -0400 |
commit | 611ce24114aac1befac6e65d85b0daa721cf71fd (patch) | |
tree | 94747c0d5ee13ccad7cb219ab225c8c93936513f /llvm/lib/Passes/PassBuilderPipelines.cpp | |
parent | b7fcf515150f7bdf052e08ebd192c8b644d2ec14 (diff) | |
download | llvm-611ce24114aac1befac6e65d85b0daa721cf71fd.zip llvm-611ce24114aac1befac6e65d85b0daa721cf71fd.tar.gz llvm-611ce24114aac1befac6e65d85b0daa721cf71fd.tar.bz2 |
[PGO] Enable `-fprofile-update` for `-fprofile-generate`
Currently, the `-fprofile-udpate` is ignored when `-fprofile-generate` is in effect. This patch enables `-fprofile-update` for `-fprofile-generate`. This patch continues the work from https://reviews.llvm.org/D87737, which added `-fprofile-update` in the first place.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D157280
Diffstat (limited to 'llvm/lib/Passes/PassBuilderPipelines.cpp')
-rw-r--r-- | llvm/lib/Passes/PassBuilderPipelines.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 660cb2e..aa42fb3 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -724,7 +724,8 @@ void PassBuilder::addRequiredLTOPreLinkPasses(ModulePassManager &MPM) { void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level, bool RunProfileGen, - bool IsCS, std::string ProfileFile, + bool IsCS, bool AtomicCounterUpdate, + std::string ProfileFile, std::string ProfileRemappingFile, ThinOrFullLTOPhase LTOPhase, IntrusiveRefCntPtr<vfs::FileSystem> FS) { @@ -793,13 +794,14 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, // Do counter promotion at Level greater than O0. Options.DoCounterPromotion = true; Options.UseBFIInPromotion = IsCS; + Options.Atomic = AtomicCounterUpdate; MPM.addPass(InstrProfiling(Options, IsCS)); } void PassBuilder::addPGOInstrPassesForO0( ModulePassManager &MPM, bool RunProfileGen, bool IsCS, - std::string ProfileFile, std::string ProfileRemappingFile, - IntrusiveRefCntPtr<vfs::FileSystem> FS) { + bool AtomicCounterUpdate, std::string ProfileFile, + std::string ProfileRemappingFile, IntrusiveRefCntPtr<vfs::FileSystem> FS) { if (!RunProfileGen) { assert(!ProfileFile.empty() && "Profile use expecting a profile file!"); MPM.addPass( @@ -819,6 +821,7 @@ void PassBuilder::addPGOInstrPassesForO0( // Do not do counter promotion at O0. Options.DoCounterPromotion = false; Options.UseBFIInPromotion = IsCS; + Options.Atomic = AtomicCounterUpdate; MPM.addPass(InstrProfiling(Options, IsCS)); } @@ -1093,9 +1096,10 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, (PGOOpt->Action == PGOOptions::IRInstr || PGOOpt->Action == PGOOptions::IRUse)) { addPGOInstrPasses(MPM, Level, - /* RunProfileGen */ PGOOpt->Action == PGOOptions::IRInstr, - /* IsCS */ false, PGOOpt->ProfileFile, - PGOOpt->ProfileRemappingFile, Phase, PGOOpt->FS); + /*RunProfileGen=*/PGOOpt->Action == PGOOptions::IRInstr, + /*IsCS=*/false, PGOOpt->AtomicCounterUpdate, + PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile, Phase, + PGOOpt->FS); MPM.addPass(PGOIndirectCallPromotion(false, false)); } if (PGOOpt && Phase != ThinOrFullLTOPhase::ThinLTOPostLink && @@ -1306,13 +1310,15 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level, // instrumentation is after all the inlines are done. if (!LTOPreLink && PGOOpt) { if (PGOOpt->CSAction == PGOOptions::CSIRInstr) - addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true, - /* IsCS */ true, PGOOpt->CSProfileGenFile, - PGOOpt->ProfileRemappingFile, LTOPhase, PGOOpt->FS); + addPGOInstrPasses(MPM, Level, /*RunProfileGen=*/true, + /*IsCS=*/true, PGOOpt->AtomicCounterUpdate, + PGOOpt->CSProfileGenFile, PGOOpt->ProfileRemappingFile, + LTOPhase, PGOOpt->FS); else if (PGOOpt->CSAction == PGOOptions::CSIRUse) - addPGOInstrPasses(MPM, Level, /* RunProfileGen */ false, - /* IsCS */ true, PGOOpt->ProfileFile, - PGOOpt->ProfileRemappingFile, LTOPhase, PGOOpt->FS); + addPGOInstrPasses(MPM, Level, /*RunProfileGen=*/false, + /*IsCS=*/true, PGOOpt->AtomicCounterUpdate, + PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile, + LTOPhase, PGOOpt->FS); } // Re-compute GlobalsAA here prior to function passes. This is particularly @@ -1787,14 +1793,14 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, // sensitive PGO pass. if (PGOOpt) { if (PGOOpt->CSAction == PGOOptions::CSIRInstr) - addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true, - /* IsCS */ true, PGOOpt->CSProfileGenFile, - PGOOpt->ProfileRemappingFile, + addPGOInstrPasses(MPM, Level, /*RunProfileGen=*/true, + /*IsCS=*/true, PGOOpt->AtomicCounterUpdate, + PGOOpt->CSProfileGenFile, PGOOpt->ProfileRemappingFile, ThinOrFullLTOPhase::FullLTOPostLink, PGOOpt->FS); else if (PGOOpt->CSAction == PGOOptions::CSIRUse) - addPGOInstrPasses(MPM, Level, /* RunProfileGen */ false, - /* IsCS */ true, PGOOpt->ProfileFile, - PGOOpt->ProfileRemappingFile, + addPGOInstrPasses(MPM, Level, /*RunProfileGen=*/false, + /*IsCS=*/true, PGOOpt->AtomicCounterUpdate, + PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile, ThinOrFullLTOPhase::FullLTOPostLink, PGOOpt->FS); } @@ -1939,9 +1945,9 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level, PGOOpt->Action == PGOOptions::IRUse)) addPGOInstrPassesForO0( MPM, - /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr), - /* IsCS */ false, PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile, - PGOOpt->FS); + /*RunProfileGen=*/(PGOOpt->Action == PGOOptions::IRInstr), + /*IsCS=*/false, PGOOpt->AtomicCounterUpdate, PGOOpt->ProfileFile, + PGOOpt->ProfileRemappingFile, PGOOpt->FS); invokePipelineStartEPCallbacks(MPM, Level); |