[PATCH] D105223: [lld-macho] Add support for LTO optimization level
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 12:05:05 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe08e9c4871e: [lld-macho] Add support for LTO optimization level (authored by lgrey, committed by thakis).
Changed prior to commit:
https://reviews.llvm.org/D105223?vs=355662&id=355967#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105223/new/
https://reviews.llvm.org/D105223
Files:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/LTO.cpp
lld/MachO/Options.td
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -64,6 +64,10 @@
HelpText<"Set level for identical code folding (default: none)">,
MetaVarName<"[none,safe,all]">,
Group<grp_lld>;
+def lto_O: Joined<["--"], "lto-O">,
+ HelpText<"Set optimization level for LTO (default: 2)">,
+ MetaVarName<"<opt-level>">,
+ Group<grp_lld>;
// This is a complete Options.td compiled from Apple's ld(1) manpage
// dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/LTO.cpp
===================================================================
--- lld/MachO/LTO.cpp
+++ lld/MachO/LTO.cpp
@@ -13,6 +13,7 @@
#include "Symbols.h"
#include "Target.h"
+#include "lld/Common/Args.h"
#include "lld/Common/ErrorHandler.h"
#include "lld/Common/Strings.h"
#include "lld/Common/TargetOptionsCommandFlags.h"
@@ -40,6 +41,8 @@
};
c.TimeTraceEnabled = config->timeTraceEnabled;
c.TimeTraceGranularity = config->timeTraceGranularity;
+ c.OptLevel = config->ltoo;
+ c.CGOptLevel = args::getCGOptLevel(config->ltoo);
if (config->saveTemps)
checkError(c.addSaveTemps(config->outputFile.str() + ".",
/*UseInputModulePath=*/true));
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1082,6 +1082,9 @@
config->ltoNewPassManager =
args.hasFlag(OPT_no_lto_legacy_pass_manager, OPT_lto_legacy_pass_manager,
LLVM_ENABLE_NEW_PASS_MANAGER);
+ config->ltoo = args::getInteger(args, OPT_lto_O, 2);
+ if (config->ltoo > 3)
+ error("--lto-O: invalid optimization level: " + Twine(config->ltoo));
config->runtimePaths = args::getStrings(args, OPT_rpath);
config->allLoad = args.hasArg(OPT_all_load);
config->forceLoadObjC = args.hasArg(OPT_ObjC);
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -126,6 +126,7 @@
llvm::StringRef outputFile;
llvm::StringRef ltoObjPath;
llvm::StringRef thinLTOJobs;
+ uint32_t ltoo = 2;
bool deadStripDylibs = false;
bool demangle = false;
bool deadStrip = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105223.355967.patch
Type: text/x-patch
Size: 2314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/df7b58ac/attachment.bin>
More information about the llvm-commits
mailing list