diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1922,6 +1922,10 @@ for (auto &C : PipelineStartEPCallbacks) C(MPM, Level); + + if (PGOOpt && PGOOpt->DebugInfoForProfiling) + MPM.addPass(createModuleToFunctionPassAdaptor(AddDiscriminatorsPass())); + for (auto &C : PipelineEarlySimplificationEPCallbacks) C(MPM, Level); diff --git a/llvm/test/Other/new-pm-O0-defaults.ll b/llvm/test/Other/new-pm-O0-defaults.ll --- a/llvm/test/Other/new-pm-O0-defaults.ll +++ b/llvm/test/Other/new-pm-O0-defaults.ll @@ -13,6 +13,9 @@ ; RUN: opt -disable-verify -verify-cfg-preserved=0 -debug-pass-manager -enable-matrix \ ; RUN: -passes='default' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT,CHECK-MATRIX +; RUN: opt -disable-verify -verify-cfg-preserved=0 -debug-pass-manager -new-pm-debug-info-for-profiling \ +; RUN: -passes='default' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DIS ; RUN: opt -disable-verify -verify-cfg-preserved=0 -debug-pass-manager \ ; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT,CHECK-PRE-LINK @@ -26,6 +29,10 @@ ; RUN: -passes='lto' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-LTO +; CHECK-DIS: Running analysis: InnerAnalysisManagerProxy +; CHECK-DIS-NEXT: Running pass: AddDiscriminatorsPass +; CHECK-DIS-NEXT: Running pass: AlwaysInlinerPass +; CHECK-DIS-NEXT: Running analysis: ProfileSummaryAnalysis ; CHECK-DEFAULT: Running pass: AlwaysInlinerPass ; CHECK-DEFAULT-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-DEFAULT-NEXT: Running analysis: ProfileSummaryAnalysis