diff options
author | Adam Nemet <anemet@apple.com> | 2016-12-02 17:54:34 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2016-12-02 17:54:34 +0000 |
commit | fc9e246463f0605e424eda14493592cdcf3bb9bf (patch) | |
tree | d8e7c9d92d4f78656211834b7e92257460893eb5 /clang/lib/Driver/Tools.cpp | |
parent | 4c207a6a1fa1d5d94e00b99770733d7c2cee21c2 (diff) | |
download | llvm-fc9e246463f0605e424eda14493592cdcf3bb9bf.zip llvm-fc9e246463f0605e424eda14493592cdcf3bb9bf.tar.gz llvm-fc9e246463f0605e424eda14493592cdcf3bb9bf.tar.bz2 |
With LTO and profile-use, enable hotness info in opt remarks
This is to match the behavior of non-LTO;
when -fsave-optimization-record is passed and PGO is available we enable
the generation of hotness information in the optimization records.
Differential Revision: https://reviews.llvm.org/D27332
llvm-svn: 288520
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 40e6dd8..e3cb962 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -3644,6 +3644,19 @@ VersionTuple visualstudio::getMSVCVersion(const Driver *D, const ToolChain &TC, return VersionTuple(); } +static Arg *getLastProfileUseArg(const ArgList &Args) { + auto *ProfileUseArg = Args.getLastArg( + options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, + options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, + options::OPT_fno_profile_instr_use); + + if (ProfileUseArg && + ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) + ProfileUseArg = nullptr; + + return ProfileUseArg; +} + static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, const InputInfo &Output, const ArgList &Args, ArgStringList &CmdArgs) { @@ -3668,13 +3681,7 @@ static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, D.Diag(diag::err_drv_argument_not_allowed_with) << PGOGenerateArg->getSpelling() << ProfileGenerateArg->getSpelling(); - auto *ProfileUseArg = Args.getLastArg( - options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, - options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, - options::OPT_fno_profile_instr_use); - if (ProfileUseArg && - ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) - ProfileUseArg = nullptr; + auto *ProfileUseArg = getLastProfileUseArg(Args); if (PGOGenerateArg && ProfileUseArg) D.Diag(diag::err_drv_argument_not_allowed_with) @@ -8436,6 +8443,11 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, F = Output.getFilename(); F += ".opt.yaml"; CmdArgs.push_back(Args.MakeArgString(F)); + + if (getLastProfileUseArg(Args)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-lto-pass-remarks-with-hotness"); + } } // It seems that the 'e' option is completely ignored for dynamic executables |