diff options
-rw-r--r-- | include/llvm-c/lto.h | 21 | ||||
-rw-r--r-- | tools/gold/gold-plugin.cpp | 22 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 62 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.h | 9 | ||||
-rw-r--r-- | tools/lto/lto.cpp | 10 | ||||
-rw-r--r-- | tools/lto/lto.exports | 2 |
6 files changed, 2 insertions, 124 deletions
diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index ce3546bd49..078502b3e6 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -259,27 +259,6 @@ lto_codegen_dispose(lto_code_gen_t); extern bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); -/* @LOCALMOD-BEGIN */ -/** - * Add an object module to the set of modules for which code will be generated. - * This does not merge the module immediately, unlike lto_codegen_add_module. - * It will hold onto the module until the user calls - * lto_codegen_link_gathered_modules_and_dispose(). The lto_module_t - * should now by owned by the lto_code_gen_t, and will be freed when - * the link is done. - */ -extern void -lto_codegen_gather_module_for_link(lto_code_gen_t cg, lto_module_t mod); - -/** - * Merges modules that are part of the set of modules gathered by - * lto_codegen_gather_module_for_link(), and the also destroys the modules - * as lto_module_dispose() would. - */ -extern bool -lto_codegen_link_gathered_modules_and_dispose(lto_code_gen_t cg); -/* @LOCALMOD-END*/ - /** * Sets if debug info should be generated. * Returns true on error (check lto_get_error_message() for details). diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 1e96762d10..2ea45dd9d3 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -96,7 +96,6 @@ namespace { namespace options { enum generate_bc { BC_NO, BC_ALSO, BC_ONLY }; static bool generate_api_file = false; - static bool gather_then_link = true; // @LOCALMOD static generate_bc generate_bc_file = BC_NO; static std::string bc_path; static std::string obj_path; @@ -126,10 +125,6 @@ namespace options { triple = opt.substr(strlen("mtriple=")); } else if (opt.startswith("obj-path=")) { obj_path = opt.substr(strlen("obj-path=")); - // @LOCALMOD-BEGIN - } else if (opt == "no-gather-then-link") { - gather_then_link = false; - // @LOCALMOD-END } else if (opt == "emit-llvm") { generate_bc_file = BC_ONLY; } else if (opt == "also-emit-llvm") { @@ -463,19 +458,12 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file, DepLibs.push_back(soname); } } else { - if (options::gather_then_link) { - lto_codegen_gather_module_for_link(code_gen, M); - } else { - lto_codegen_add_module(code_gen, M); - } + lto_codegen_add_module(code_gen, M); cf.is_linked_in = true; } } - // With gather_then_link, the modules are disposed when linking. - if (!options::gather_then_link) - lto_module_dispose(M); - // @LOCALMOD-END + lto_module_dispose(M); return LDPS_OK; } @@ -488,12 +476,6 @@ static ld_plugin_status all_symbols_read_hook(void) { std::ofstream api_file; assert(code_gen); - // @LOCALMOD-BEGIN - if (options::gather_then_link) { - lto_codegen_link_gathered_modules_and_dispose(code_gen); - } - // @LOCALMOD-END - if (options::generate_api_file) { api_file.open("apifile.txt", std::ofstream::out | std::ofstream::trunc); if (!api_file.is_open()) { diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 5a597d001d..b716da5707 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -98,68 +98,6 @@ bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg) { return ret; } -// @LOCALMOD-BEGIN -/// Add a module that will be merged with the final output module. -/// The merging does not happen until linkGatheredModulesAndDispose(). -void LTOCodeGenerator::gatherModuleForLinking(LTOModule* mod) { - _gatheredModules.push_back(mod); -} - -/// Merge all modules gathered from gatherModuleForLinking(), and -/// destroy the source modules in the process. -bool LTOCodeGenerator::linkGatheredModulesAndDispose(std::string& errMsg) { - - // We gather the asm undefs earlier than addModule() does, - // since we delete the modules during linking, and would not be - // able to do this after linking. The undefs vector contain lists - // of global variable names which are considered "used", which will be - // appended into the "llvm.compiler.used" list. The names must be the - // same before linking as they are after linking, since we have switched - // the order. - for (unsigned i = 0, ei = _gatheredModules.size(); i != ei; ++i) { - const std::vector<const char*> &undefs = - _gatheredModules[i]->getAsmUndefinedRefs(); - for (int j = 0, ej = undefs.size(); j != ej; ++j) { - _asmUndefinedRefs[undefs[j]] = 1; - } - } - - // Tree-reduce the mods, re-using the incoming mods as scratch - // intermediate results. Module i is linked with (i + stride), with i as - // the dest. We begin with a stride of 1, and double each time. E.g., - // after the first round, only the even-indexed modules are still available, - // and after the second, only those with index that are a multiple of 4 - // are available. Eventually the Module with the content of all other modules - // will be Module 0. - // NOTE: we may be able to be smarter about linking if we did not do them - // pairwise using Linker::LinkModules. We also disregard module sizes - // and try our best to keep the modules in order (linking adjacent modules). - for (unsigned stride = 1, len = _gatheredModules.size(); - stride < len; - stride *= 2) { - for (unsigned i = 0; i + stride < len; i = i + (stride * 2)) { - if (Linker::LinkModules(_gatheredModules[i]->getLLVVMModule(), - _gatheredModules[i+stride]->getLLVVMModule(), - Linker::DestroySource, &errMsg)) { - errs() << "LinkModules " << i << " w/ " << i + stride << " failed...\n"; - // We leak the memory in this case... - return true; - } - delete _gatheredModules[i+stride]; - } - } - - // Finally, link Node 0 with the Dest and delete Node 0. - if (_linker.linkInModule(_gatheredModules[0]->getLLVVMModule(), &errMsg)) { - errs() << "LinkModules Dst w/ _gatheredModules[0] failed...\n"; - return true; - } - delete _gatheredModules[0]; - - return false; -} -// @LOCALMOD-END - bool LTOCodeGenerator::setDebugInfo(lto_debug_model debug, std::string& errMsg) { switch (debug) { diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h index 4cc3928340..5a78488e29 100644 --- a/tools/lto/LTOCodeGenerator.h +++ b/tools/lto/LTOCodeGenerator.h @@ -41,12 +41,6 @@ struct LTOCodeGenerator { ~LTOCodeGenerator(); bool addModule(struct LTOModule*, std::string &errMsg); - // @LOCALMOD-BEGIN - // Alternative methods of adding modules, which delay merging modules until - // all modules are available. - void gatherModuleForLinking(struct LTOModule*); - bool linkGatheredModulesAndDispose(std::string &errMsg); - // @LOCALMOD-END bool setDebugInfo(lto_debug_model, std::string &errMsg); bool setCodePICModel(lto_codegen_model, std::string &errMsg); @@ -94,9 +88,6 @@ private: std::vector<char*> _codegenOptions; std::string _mCpu; std::string _nativeObjectPath; - - // @LOCALMOD - std::vector<LTOModule*> _gatheredModules; }; #endif // LTO_CODE_GENERATOR_H diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 1915acbdae..11d54c6a9d 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -204,16 +204,6 @@ bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) { return cg->addModule(mod, sLastErrorString); } -// @LOCALMOD-BEGIN -void lto_codegen_gather_module_for_link(lto_code_gen_t cg, lto_module_t mod) { - cg->gatherModuleForLinking(mod); -} - -bool lto_codegen_link_gathered_modules_and_dispose(lto_code_gen_t cg) { - return cg->linkGatheredModulesAndDispose(sLastErrorString); -} -// @LOCALMOD-END - /// lto_codegen_set_debug_model - Sets what if any format of debug info should /// be generated. Returns true on error (check lto_get_error_message() for /// details). diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports index 10d2fe03f6..596d2d6ec3 100644 --- a/tools/lto/lto.exports +++ b/tools/lto/lto.exports @@ -22,8 +22,6 @@ lto_module_is_object_file_in_memory lto_module_is_object_file_in_memory_for_target lto_module_dispose lto_codegen_add_module -lto_codegen_gather_module_for_link -lto_codegen_link_gathered_modules_and_dispose lto_codegen_add_must_preserve_symbol lto_codegen_compile lto_codegen_create |