@@ -724,7 +724,8 @@ void PassBuilder::addRequiredLTOPreLinkPasses(ModulePassManager &MPM) {
724
724
725
725
void PassBuilder::addPGOInstrPasses (ModulePassManager &MPM,
726
726
OptimizationLevel Level, bool RunProfileGen,
727
- bool IsCS, std::string ProfileFile,
727
+ bool IsCS, bool AtomicCounterUpdate,
728
+ std::string ProfileFile,
728
729
std::string ProfileRemappingFile,
729
730
ThinOrFullLTOPhase LTOPhase,
730
731
IntrusiveRefCntPtr<vfs::FileSystem> FS) {
@@ -793,13 +794,14 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM,
793
794
// Do counter promotion at Level greater than O0.
794
795
Options.DoCounterPromotion = true ;
795
796
Options.UseBFIInPromotion = IsCS;
797
+ Options.Atomic = AtomicCounterUpdate;
796
798
MPM.addPass (InstrProfiling (Options, IsCS));
797
799
}
798
800
799
801
void PassBuilder::addPGOInstrPassesForO0 (
800
802
ModulePassManager &MPM, bool RunProfileGen, bool IsCS,
801
- std::string ProfileFile , std::string ProfileRemappingFile ,
802
- IntrusiveRefCntPtr<vfs::FileSystem> FS) {
803
+ bool AtomicCounterUpdate , std::string ProfileFile ,
804
+ std::string ProfileRemappingFile, IntrusiveRefCntPtr<vfs::FileSystem> FS) {
803
805
if (!RunProfileGen) {
804
806
assert (!ProfileFile.empty () && " Profile use expecting a profile file!" );
805
807
MPM.addPass (
@@ -819,6 +821,7 @@ void PassBuilder::addPGOInstrPassesForO0(
819
821
// Do not do counter promotion at O0.
820
822
Options.DoCounterPromotion = false ;
821
823
Options.UseBFIInPromotion = IsCS;
824
+ Options.Atomic = AtomicCounterUpdate;
822
825
MPM.addPass (InstrProfiling (Options, IsCS));
823
826
}
824
827
@@ -1093,9 +1096,10 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
1093
1096
(PGOOpt->Action == PGOOptions::IRInstr ||
1094
1097
PGOOpt->Action == PGOOptions::IRUse)) {
1095
1098
addPGOInstrPasses (MPM, Level,
1096
- /* RunProfileGen */ PGOOpt->Action == PGOOptions::IRInstr,
1097
- /* IsCS */ false , PGOOpt->ProfileFile ,
1098
- PGOOpt->ProfileRemappingFile , Phase, PGOOpt->FS );
1099
+ /* RunProfileGen=*/ PGOOpt->Action == PGOOptions::IRInstr,
1100
+ /* IsCS=*/ false , PGOOpt->AtomicCounterUpdate ,
1101
+ PGOOpt->ProfileFile , PGOOpt->ProfileRemappingFile , Phase,
1102
+ PGOOpt->FS );
1099
1103
MPM.addPass (PGOIndirectCallPromotion (false , false ));
1100
1104
}
1101
1105
if (PGOOpt && Phase != ThinOrFullLTOPhase::ThinLTOPostLink &&
@@ -1306,13 +1310,15 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
1306
1310
// instrumentation is after all the inlines are done.
1307
1311
if (!LTOPreLink && PGOOpt) {
1308
1312
if (PGOOpt->CSAction == PGOOptions::CSIRInstr)
1309
- addPGOInstrPasses (MPM, Level, /* RunProfileGen */ true ,
1310
- /* IsCS */ true , PGOOpt->CSProfileGenFile ,
1311
- PGOOpt->ProfileRemappingFile , LTOPhase, PGOOpt->FS );
1313
+ addPGOInstrPasses (MPM, Level, /* RunProfileGen=*/ true ,
1314
+ /* IsCS=*/ true , PGOOpt->AtomicCounterUpdate ,
1315
+ PGOOpt->CSProfileGenFile , PGOOpt->ProfileRemappingFile ,
1316
+ LTOPhase, PGOOpt->FS );
1312
1317
else if (PGOOpt->CSAction == PGOOptions::CSIRUse)
1313
- addPGOInstrPasses (MPM, Level, /* RunProfileGen */ false ,
1314
- /* IsCS */ true , PGOOpt->ProfileFile ,
1315
- PGOOpt->ProfileRemappingFile , LTOPhase, PGOOpt->FS );
1318
+ addPGOInstrPasses (MPM, Level, /* RunProfileGen=*/ false ,
1319
+ /* IsCS=*/ true , PGOOpt->AtomicCounterUpdate ,
1320
+ PGOOpt->ProfileFile , PGOOpt->ProfileRemappingFile ,
1321
+ LTOPhase, PGOOpt->FS );
1316
1322
}
1317
1323
1318
1324
// Re-compute GlobalsAA here prior to function passes. This is particularly
@@ -1787,14 +1793,14 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
1787
1793
// sensitive PGO pass.
1788
1794
if (PGOOpt) {
1789
1795
if (PGOOpt->CSAction == PGOOptions::CSIRInstr)
1790
- addPGOInstrPasses (MPM, Level, /* RunProfileGen */ true ,
1791
- /* IsCS */ true , PGOOpt->CSProfileGenFile ,
1792
- PGOOpt->ProfileRemappingFile ,
1796
+ addPGOInstrPasses (MPM, Level, /* RunProfileGen= */ true ,
1797
+ /* IsCS= */ true , PGOOpt->AtomicCounterUpdate ,
1798
+ PGOOpt->CSProfileGenFile , PGOOpt-> ProfileRemappingFile ,
1793
1799
ThinOrFullLTOPhase::FullLTOPostLink, PGOOpt->FS );
1794
1800
else if (PGOOpt->CSAction == PGOOptions::CSIRUse)
1795
- addPGOInstrPasses (MPM, Level, /* RunProfileGen */ false ,
1796
- /* IsCS */ true , PGOOpt->ProfileFile ,
1797
- PGOOpt->ProfileRemappingFile ,
1801
+ addPGOInstrPasses (MPM, Level, /* RunProfileGen= */ false ,
1802
+ /* IsCS= */ true , PGOOpt->AtomicCounterUpdate ,
1803
+ PGOOpt->ProfileFile , PGOOpt-> ProfileRemappingFile ,
1798
1804
ThinOrFullLTOPhase::FullLTOPostLink, PGOOpt->FS );
1799
1805
}
1800
1806
@@ -1939,9 +1945,9 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
1939
1945
PGOOpt->Action == PGOOptions::IRUse))
1940
1946
addPGOInstrPassesForO0 (
1941
1947
MPM,
1942
- /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr),
1943
- /* IsCS */ false , PGOOpt->ProfileFile , PGOOpt->ProfileRemappingFile ,
1944
- PGOOpt->FS );
1948
+ /* RunProfileGen= */ (PGOOpt->Action == PGOOptions::IRInstr),
1949
+ /* IsCS= */ false , PGOOpt->AtomicCounterUpdate , PGOOpt->ProfileFile ,
1950
+ PGOOpt->ProfileRemappingFile , PGOOpt-> FS );
1945
1951
1946
1952
invokePipelineStartEPCallbacks (MPM, Level);
1947
1953
0 commit comments