diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -1202,7 +1202,8 @@ // Now add the optimization pipeline. MPM.addPass(buildModuleOptimizationPipeline(Level, LTOPreLink)); - if (PGOOpt && PGOOpt->PseudoProbeForProfiling) + if (PGOOpt && PGOOpt->PseudoProbeForProfiling && + PGOOpt->Action == PGOOptions::SampleUse) MPM.addPass(PseudoProbeUpdatePass()); // Emit annotation remarks. @@ -1258,7 +1259,8 @@ // on these, we schedule the cleanup here. MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass())); - if (PGOOpt && PGOOpt->PseudoProbeForProfiling) + if (PGOOpt && PGOOpt->PseudoProbeForProfiling && + PGOOpt->Action == PGOOptions::SampleUse) MPM.addPass(PseudoProbeUpdatePass()); // Handle OptimizerLastEPCallbacks added by clang on PreLink. Actual