diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 12 | ||||
-rw-r--r-- | llvm/tools/lto/lto.cpp | 15 | ||||
-rw-r--r-- | llvm/tools/lto/lto.exports | 5 |
3 files changed, 31 insertions, 1 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index 2f0a1dfb9fa..ece0130c9fb 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -130,6 +130,11 @@ static cl::opt<std::string> ThinLTOSaveTempsPrefix( cl::desc("Save ThinLTO temp files using filenames created by adding " "suffixes to the given file path prefix.")); +static cl::opt<std::string> ThinLTOGeneratedObjectsDir( + "thinlto-save-objects", + cl::desc("Save ThinLTO generated object files using filenames created in " + "the given directory.")); + static cl::opt<bool> SaveModuleFile("save-merged-module", cl::init(false), cl::desc("Write merged LTO module to file before CodeGen")); @@ -707,6 +712,13 @@ private: if (!ThinLTOSaveTempsPrefix.empty()) ThinGenerator.setSaveTempsDir(ThinLTOSaveTempsPrefix); + + if (!ThinLTOGeneratedObjectsDir.empty()) { + ThinGenerator.setGeneratedObjectsDirectory(ThinLTOGeneratedObjectsDir); + ThinGenerator.run(); + return; + } + ThinGenerator.run(); auto &Binaries = ThinGenerator.getProducedBinaries(); diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 2f0dd26d64d..aa61f2ad2ff 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -488,6 +488,16 @@ LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg, MemBuffer->getBufferSize()}; } +unsigned int thinlto_module_get_num_object_files(thinlto_code_gen_t cg) { + return unwrap(cg)->getProducedBinaryFiles().size(); +} +const char *thinlto_module_get_object_file(thinlto_code_gen_t cg, + unsigned int index) { + assert(index < unwrap(cg)->getProducedBinaryFiles().size() && + "Index overflow"); + return unwrap(cg)->getProducedBinaryFiles()[index].c_str(); +} + void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg, lto_bool_t disable) { unwrap(cg)->disableCodeGen(disable); @@ -551,6 +561,11 @@ void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg, return unwrap(cg)->setSaveTempsDir(save_temps_dir); } +void thinlto_set_generated_objects_dir(thinlto_code_gen_t cg, + const char *save_temps_dir) { + unwrap(cg)->setGeneratedObjectsDirectory(save_temps_dir); +} + lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg, lto_codegen_model model) { switch (model) { diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports index 74091c2641b..2e09026ae50 100644 --- a/llvm/tools/lto/lto.exports +++ b/llvm/tools/lto/lto.exports @@ -64,4 +64,7 @@ thinlto_codegen_add_must_preserve_symbol thinlto_codegen_add_cross_referenced_symbol thinlto_codegen_set_final_cache_size_relative_to_available_space thinlto_codegen_set_codegen_only -thinlto_codegen_disable_codegen
\ No newline at end of file +thinlto_codegen_disable_codegen +thinlto_module_get_num_object_files +thinlto_module_get_object_file +thinlto_set_generated_objects_dir
\ No newline at end of file |