forked from OSchip/llvm-project
[lld-macho] Add support for LTO optimization level
Everything (including test) modified from ELF/COFF. Using the same syntax (--lto-O3, etc) as ELF. Differential Revision: https://reviews.llvm.org/D105223
This commit is contained in:
parent
33b579c8a5
commit
fe08e9c487
|
@ -126,6 +126,7 @@ struct Configuration {
|
|||
llvm::StringRef outputFile;
|
||||
llvm::StringRef ltoObjPath;
|
||||
llvm::StringRef thinLTOJobs;
|
||||
uint32_t ltoo = 2;
|
||||
bool deadStripDylibs = false;
|
||||
bool demangle = false;
|
||||
bool deadStrip = false;
|
||||
|
|
|
@ -1082,6 +1082,9 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
|||
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);
|
||||
|
|
|
@ -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 @@ static lto::Config createConfig() {
|
|||
};
|
||||
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));
|
||||
|
|
|
@ -64,6 +64,10 @@ def icf_eq: Joined<["--"], "icf=">,
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue