[CSSPGO] Enable pseudo probe instrumentation in O0 mode.

Pseudo probe instrumentation was missing from O0 build. It is needed in cases where some source files are built in O0 while the others are built in optimize mode.

Reviewed By: wenlei, wlei, wmi

Differential Revision: https://reviews.llvm.org/D109531
This commit is contained in:
Hongtao Yu 2021-09-09 11:41:39 -07:00
parent 962acf0a27
commit 299b5d420d
2 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,4 @@
// RUN: %clang_cc1 -O0 -fno-legacy-pass-manager -fpseudo-probe-for-profiling -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -O2 -fno-legacy-pass-manager -fpseudo-probe-for-profiling -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
// Check the generation of pseudoprobe intrinsic call

View File

@ -1924,6 +1924,13 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
ModulePassManager MPM;
// Perform pseudo probe instrumentation in O0 mode. This is for the
// consistency between different build modes. For example, a LTO build can be
// mixed with an O0 prelink and an O2 postlink. Loading a sample profile in
// the postlink will require pseudo probe instrumentation in the prelink.
if (PGOOpt && PGOOpt->PseudoProbeForProfiling)
MPM.addPass(SampleProfileProbePass(TM));
if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr ||
PGOOpt->Action == PGOOptions::IRUse))
addPGOInstrPassesForO0(