From 4564ed1430774e84b49adaee633dbf1699104c76 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 6 Apr 2018 21:14:33 +0000 Subject: [PATCH] Revert r324557, "gold-plugin: Do not set codegen opt level based on LTO opt level." It was reported that this change measurably regressed -plugin-opt=O3 performance. There is an ongoing discussion on llvm-dev about the correct way to set the CG opt level, see thread "[llvm-dev] [RFC] Adding function attributes to represent codegen optimization level". llvm-svn: 329458 --- llvm/tools/gold/gold-plugin.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index d2d0e77..6123b8e 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -779,6 +779,20 @@ static int getOutputFileName(StringRef InFilename, bool TempOutFile, return FD; } +static CodeGenOpt::Level getCGOptLevel() { + switch (options::OptLevel) { + case 0: + return CodeGenOpt::None; + case 1: + return CodeGenOpt::Less; + case 2: + return CodeGenOpt::Default; + case 3: + return CodeGenOpt::Aggressive; + } + llvm_unreachable("Invalid optimization level"); +} + /// Parse the thinlto_prefix_replace option into the \p OldPrefix and /// \p NewPrefix strings, if it was specified. static void getThinLTOOldAndNewPrefix(std::string &OldPrefix, @@ -810,6 +824,7 @@ static std::unique_ptr createLTO(IndexWriteCallback OnIndexWrite, Conf.MAttrs = MAttrs; Conf.RelocModel = RelocationModel; + Conf.CGOptLevel = getCGOptLevel(); Conf.DisableVerify = options::DisableVerify; Conf.OptLevel = options::OptLevel; if (options::Parallelism) -- 2.7.4