diff options
author | Scott Linder <Scott.Linder@amd.com> | 2023-01-16 23:55:22 +0000 |
---|---|---|
committer | Scott Linder <Scott.Linder@amd.com> | 2023-01-23 22:50:49 +0000 |
commit | 25c0ea2a5370813f46686918a84e0de27e107d08 (patch) | |
tree | 2c84becaf6fd5a50a9529674bdde2fe4f9400b55 /llvm/tools/gold | |
parent | 02fd0020e5771b2850f892712b8fa51d3b98e270 (diff) | |
download | llvm-25c0ea2a5370813f46686918a84e0de27e107d08.zip llvm-25c0ea2a5370813f46686918a84e0de27e107d08.tar.gz llvm-25c0ea2a5370813f46686918a84e0de27e107d08.tar.bz2 |
[NFC] Consolidate llvm::CodeGenOpt::Level handling
Add free functions llvm::CodeGenOpt::{getLevel,getID,parseLevel} to
provide common implementations for functionality that has been
duplicated in many places across the codebase.
Differential Revision: https://reviews.llvm.org/D141968
Diffstat (limited to 'llvm/tools/gold')
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 660f51c..939dbaf 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -846,20 +846,6 @@ 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, @@ -896,7 +882,10 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite, Conf.MAttrs = codegen::getMAttrs(); Conf.RelocModel = RelocationModel; Conf.CodeModel = codegen::getExplicitCodeModel(); - Conf.CGOptLevel = getCGOptLevel(); + std::optional<CodeGenOpt::Level> CGOptLevelOrNone = + CodeGenOpt::getLevel(options::OptLevel); + assert(CGOptLevelOrNone && "Invalid optimization level"); + Conf.CGOptLevel = *CGOptLevelOrNone; Conf.DisableVerify = options::DisableVerify; Conf.OptLevel = options::OptLevel; Conf.PTO.LoopVectorization = options::OptLevel > 1; |