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
This commit is contained in:
Peter Collingbourne 2018-04-06 21:14:33 +00:00
parent 826f58a2cb
commit 8c35013df2

View File

@ -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<LTO> createLTO(IndexWriteCallback OnIndexWrite,
Conf.MAttrs = MAttrs;
Conf.RelocModel = RelocationModel;
Conf.CGOptLevel = getCGOptLevel();
Conf.DisableVerify = options::DisableVerify;
Conf.OptLevel = options::OptLevel;
if (options::Parallelism)