diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -119,6 +119,10 @@ cl::Hidden); } +static cl::opt SaveTemps( + "save-temps", cl::init(false), + cl::desc("Save temporary LTO files in the current working directory.")); + LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context) : Context(Context), MergedModule(new Module("ld-temp.o", Context)), TheLinker(new Linker(*MergedModule)) { @@ -545,6 +549,9 @@ // Add an appropriate DataLayout instance for this module... MergedModule->setDataLayout(TargetMach->createDataLayout()); + if (Config.PostImportModuleHook) + Config.PostImportModuleHook(0, *MergedModule); + ModuleSummaryIndex CombinedIndex(false); TargetMach = createTargetMachine(); if (!opt(Config, TargetMach.get(), 0, *MergedModule, /*IsThinLTO=*/false, @@ -606,8 +613,13 @@ CodegenArgv.push_back(Arg.c_str()); cl::ParseCommandLineOptions(CodegenArgv.size(), CodegenArgv.data()); } -} + if (SaveTemps) { + if (Config.addSaveTemps("ld-temp.", + /* UseInputModulePath */ true)) + errs() << "Warning: failed to set up path to save temporary files\n"; + } +} void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI) { // Map the LLVM internal diagnostic severity to the LTO diagnostic severity.