Index: include/llvm/Passes/PassBuilder.h =================================================================== --- include/llvm/Passes/PassBuilder.h +++ include/llvm/Passes/PassBuilder.h @@ -44,6 +44,7 @@ class PassBuilder { TargetMachine *TM; Optional PGOOpt; + bool DebugInfoForProfiling; public: /// \brief A struct to capture parsed pass pipeline names. @@ -146,8 +147,9 @@ }; explicit PassBuilder(TargetMachine *TM = nullptr, - Optional PGOOpt = None) - : TM(TM), PGOOpt(PGOOpt) {} + Optional PGOOpt = None, + bool DebugInfoForProfiling = false) + : TM(TM), PGOOpt(PGOOpt), DebugInfoForProfiling(DebugInfoForProfiling) {} /// \brief Cross register the analysis managers through their proxies. /// Index: lib/Passes/PassBuilder.cpp =================================================================== --- lib/Passes/PassBuilder.cpp +++ lib/Passes/PassBuilder.cpp @@ -330,6 +330,9 @@ assert(Level != O0 && "Must request optimizations!"); FunctionPassManager FPM(DebugLogging); + if (DebugInfoForProfiling) + FPM.addPass(AddDiscriminatorsPass()); + // Form SSA out of local memory accesses after breaking apart aggregates into // scalars. FPM.addPass(SROA());