Chromium Code Reviews| Index: llvm/tools/gold/gold-plugin.cpp |
| =================================================================== |
| --- a/llvm/tools/gold/gold-plugin.cpp |
| +++ b/llvm/tools/gold/gold-plugin.cpp |
| @@ -99,6 +99,7 @@ |
| 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; |
| @@ -128,6 +129,10 @@ |
| 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; |
|
jvoung (off chromium)
2012/08/01 17:11:01
changed this flag to be "no-gather-..." so that on
|
| + // @LOCALMOD-END |
| } else if (opt == "emit-llvm") { |
| generate_bc_file = BC_ONLY; |
| } else if (opt == "also-emit-llvm") { |
| @@ -461,14 +466,20 @@ |
| DepLibs.push_back(soname); |
| } |
| } else { |
| - lto_codegen_add_module(code_gen, M); |
| + if (options::gather_then_link) { |
| + lto_codegen_gather_module_for_link(code_gen, M); |
| + } else { |
| + 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; |
| } |
| @@ -480,6 +491,12 @@ |
| 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()) { |