From: Dehao Chen Date: Thu, 27 Jul 2017 15:29:53 +0000 (+0000) Subject: Make new PM honor -fdebug-info-for-profiling (clang side) X-Git-Tag: llvmorg-6.0.0-rc1~11606 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c76a27e3257c54948df7fa969042d098c7569be8;p=platform%2Fupstream%2Fllvm.git Make new PM honor -fdebug-info-for-profiling (clang side) Summary: The new PM needs to invoke add-discriminator pass when building with -fdebug-info-for-profiling. Reviewers: chandlerc, davidxl Reviewed By: chandlerc Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D35746 llvm-svn: 309282 --- diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index b56d399..a782cc7 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -840,28 +840,27 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( return; TheModule->setDataLayout(TM->createDataLayout()); - PGOOptions PGOOpt; - - // -fprofile-generate. - PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr(); - if (PGOOpt.RunProfileGen) - PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ? - DefaultProfileGenName : CodeGenOpts.InstrProfileOutput; - - // -fprofile-use. - if (CodeGenOpts.hasProfileIRUse()) - PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath; - - if (!CodeGenOpts.SampleProfileFile.empty()) - PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile; - - // Only pass a PGO options struct if -fprofile-generate or - // -fprofile-use were passed on the cmdline. - PassBuilder PB(TM.get(), - (PGOOpt.RunProfileGen || - !PGOOpt.ProfileUseFile.empty() || - !PGOOpt.SampleProfileFile.empty()) ? - Optional(PGOOpt) : None); + Optional PGOOpt; + + if (CodeGenOpts.hasProfileIRInstr()) + // -fprofile-generate. + PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty() + ? DefaultProfileGenName + : CodeGenOpts.InstrProfileOutput, + "", "", true, CodeGenOpts.DebugInfoForProfiling); + else if (CodeGenOpts.hasProfileIRUse()) + // -fprofile-use. + PGOOpt = PGOOptions("", CodeGenOpts.ProfileInstrumentUsePath, "", false, + CodeGenOpts.DebugInfoForProfiling); + else if (!CodeGenOpts.SampleProfileFile.empty()) + // -fprofile-sample-use + PGOOpt = PGOOptions("", "", CodeGenOpts.SampleProfileFile, false, + CodeGenOpts.DebugInfoForProfiling); + else if (CodeGenOpts.DebugInfoForProfiling) + // -fdebug-info-for-profiling + PGOOpt = PGOOptions("", "", "", false, true); + + PassBuilder PB(TM.get(), PGOOpt); LoopAnalysisManager LAM; FunctionAnalysisManager FAM;