llvm.org GIT mirror llvm / 0e95b3a
Fix option parsing in the gold plugin. This was broken when options were moved up in r191680. No test because this is specific LLVMgold.so/libLTO.so. Patch by Tom Roeder! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191829 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
3 changed file(s) with 27 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
7878 // and LTOCodeGenerator::writeMergedModules().
7979 //
8080 void setCodeGenDebugOptions(const char *opts);
81
82 // Parse the options set in setCodeGenDebugOptions. Like
83 // setCodeGenDebugOptions, this must be called before
84 // LTOCodeGenerator::compilexxx() and LTOCodeGenerator::writeMergedModules()
85 void parseCodeGenDebugOptions();
8186
8287 // Write the merged module to the file specified by the given path.
8388 // Return true on success.
263263 if (TargetMach != NULL)
264264 return true;
265265
266 // if options were requested, set them
267 if (!CodegenOptions.empty())
268 cl::ParseCommandLineOptions(CodegenOptions.size(),
269 const_cast(&CodegenOptions[0]));
270
271266 std::string TripleStr = Linker.getModule()->getTargetTriple();
272267 if (TripleStr.empty())
273268 TripleStr = sys::getDefaultTargetTriple();
472467 CodegenOptions.push_back(strdup(o.first.str().c_str()));
473468 }
474469 }
470
471 void LTOCodeGenerator::parseCodeGenDebugOptions() {
472 // if options were requested, set them
473 if (!CodegenOptions.empty())
474 cl::ParseCommandLineOptions(CodegenOptions.size(),
475 const_cast(&CodegenOptions[0]));
476 }
3838 // Holds the initialization state of the LTO module.
3939 // *** Not thread safe ***
4040 static bool initialized = false;
41
42 // Holds the command-line option parsing state of the LTO module.
43 static bool parsedOptions = false;
4144
4245 // Initialize the configured targets if they have not been initialized.
4346 static void lto_initialize() {
260263 /// that contains the merged contents of all modules added so far. Returns true
261264 /// on error (check lto_get_error_message() for details).
262265 bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
266 if (!parsedOptions) {
267 cg->parseCodeGenDebugOptions();
268 parsedOptions = true;
269 }
263270 return !cg->writeMergedModules(path, sLastErrorString);
264271 }
265272
270277 /// lto_codegen_compile() is called again. On failure, returns NULL (check
271278 /// lto_get_error_message() for details).
272279 const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
280 if (!parsedOptions) {
281 cg->parseCodeGenDebugOptions();
282 parsedOptions = true;
283 }
273284 return cg->compile(length, DisableOpt, DisableInline, DisableGVNLoadPRE,
274285 sLastErrorString);
275286 }
278289 /// native object file. The name of the file is written to name. Returns true on
279290 /// error.
280291 bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
292 if (!parsedOptions) {
293 cg->parseCodeGenDebugOptions();
294 parsedOptions = true;
295 }
281296 return !cg->compile_to_file(name, DisableOpt, DisableInline, DisableGVNLoadPRE,
282297 sLastErrorString);
283298 }