diff options
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp b/contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp index 0bd9078f2d8c..1745b7449714 100644 --- a/contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/contrib/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp @@ -78,17 +78,6 @@ static cl::opt<bool> DisableVerify( "disable-verify", cl::init(false), cl::desc("Do not run the verifier during the optimization pipeline")); -static cl::opt<bool> DisableInline("disable-inlining", cl::init(false), - cl::desc("Do not run the inliner pass")); - -static cl::opt<bool> - DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false), - cl::desc("Do not run the GVN load PRE pass")); - -static cl::opt<bool> DisableLTOVectorization( - "disable-lto-vectorization", cl::init(false), - cl::desc("Do not run loop or slp vectorization during LTO")); - static cl::opt<bool> EnableFreestanding( "lto-freestanding", cl::init(false), cl::desc("Enable Freestanding (disable builtins / TLI) during LTO")); @@ -181,6 +170,10 @@ static cl::opt<std::string> ThinLTOGeneratedObjectsDir( cl::desc("Save ThinLTO generated object files using filenames created in " "the given directory.")); +static cl::opt<bool> SaveLinkedModuleFile( + "save-linked-module", cl::init(false), + cl::desc("Write linked LTO module to file before optimize")); + static cl::opt<bool> SaveModuleFile("save-merged-module", cl::init(false), cl::desc("Write merged LTO module to file before CodeGen")); @@ -333,7 +326,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer, } /// Print some statistics on the index for each input files. -void printIndexStats() { +static void printIndexStats() { for (auto &Filename : InputFilenames) { ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': "); std::unique_ptr<ModuleSummaryIndex> Index = @@ -414,7 +407,7 @@ static void printMachOCPUOnly() { LLVMContext Context; Context.setDiagnosticHandler(std::make_unique<LLVMLTODiagnosticHandler>(), true); - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); for (auto &Filename : InputFilenames) { ErrorOr<std::unique_ptr<LTOModule>> ModuleOrErr = LTOModule::createFromFile(Context, Filename, Options); @@ -461,7 +454,7 @@ static void createCombinedModuleSummaryIndex() { static void getThinLTOOldAndNewPrefix(std::string &OldPrefix, std::string &NewPrefix) { assert(ThinLTOPrefixReplace.empty() || - ThinLTOPrefixReplace.find(";") != StringRef::npos); + ThinLTOPrefixReplace.find(';') != StringRef::npos); StringRef PrefixReplace = ThinLTOPrefixReplace; std::pair<StringRef, StringRef> Split = PrefixReplace.split(";"); OldPrefix = Split.first.str(); @@ -903,7 +896,7 @@ int main(int argc, char **argv) { InitializeAllAsmParsers(); // set up the TargetOptions for the machine - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); if (ListSymbolsOnly) { listSymbols(Options); @@ -960,6 +953,7 @@ int main(int argc, char **argv) { true); LTOCodeGenerator CodeGen(Context); + CodeGen.setDisableVerify(DisableVerify); if (UseDiagnosticHandler) CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr); @@ -1018,19 +1012,22 @@ int main(int argc, char **argv) { CodeGen.setCpu(codegen::getMCPU().c_str()); CodeGen.setOptLevel(OptLevel - '0'); - - auto MAttrs = codegen::getMAttrs(); - if (!MAttrs.empty()) { - std::string attrs = join(MAttrs, ","); - CodeGen.setAttr(attrs); - } + CodeGen.setAttrs(codegen::getMAttrs()); if (auto FT = codegen::getExplicitFileType()) CodeGen.setFileType(FT.getValue()); if (!OutputFilename.empty()) { - if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE, - DisableLTOVectorization)) { + if (SaveLinkedModuleFile) { + std::string ModuleFilename = OutputFilename; + ModuleFilename += ".linked.bc"; + std::string ErrMsg; + + if (!CodeGen.writeMergedModules(ModuleFilename)) + error("writing linked module failed."); + } + + if (!CodeGen.optimize()) { // Diagnostic messages should have been printed by the handler. error("error optimizing the code"); } @@ -1071,8 +1068,7 @@ int main(int argc, char **argv) { error(": -save-merged-module must be specified with -o"); const char *OutputName = nullptr; - if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline, - DisableGVNLoadPRE, DisableLTOVectorization)) + if (!CodeGen.compile_to_file(&OutputName)) error("error compiling the code"); // Diagnostic messages should have been printed by the handler. |