Author: Hongtao Yu Date: 2021-09-14T18:13:29-07:00 New Revision: 299b5d420df15fafc9936bc24995f6cd6ad325be
URL: https://github.com/llvm/llvm-project/commit/299b5d420df15fafc9936bc24995f6cd6ad325be DIFF: https://github.com/llvm/llvm-project/commit/299b5d420df15fafc9936bc24995f6cd6ad325be.diff LOG: [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 Added: Modified: clang/test/CodeGen/pseudo-probe-emit.c llvm/lib/Passes/PassBuilder.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/pseudo-probe-emit.c b/clang/test/CodeGen/pseudo-probe-emit.c index 5fe1d23846763..b4e6a014d474b 100644 --- a/clang/test/CodeGen/pseudo-probe-emit.c +++ b/clang/test/CodeGen/pseudo-probe-emit.c @@ -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 diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 6c3241ba3e52c..076ff95cb8d21 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1924,6 +1924,13 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level, ModulePassManager MPM; + // Perform pseudo probe instrumentation in O0 mode. This is for the + // consistency between diff erent 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( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits