[llvm-dev] libLTO Codegen options issue

Wael Yehia via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 3 14:57:15 PST 2020


Hi,
We're trying to use libLTO, and noticed an issue (more of a timing problem) with option processing where TargetOptions is created before cl::ParseCommandLineOptions is invoked.
Right now, the only place where 
  ParseCommandLineOptions is called is in LTOCodeGenerator::parseCodeGenDebugOptions, 
  which is only called from maybeParseOptions,
  which is called after TargetOptions have been created.
We construct TargetOptions (by calling InitTargetOptionsFromCodeGenFlags) first and then use it to we create modules or the codegen object.

Assuming this is in fact a problem, one way to fix this is to decouple parseCodeGenDebugOptions from LTOCodeGenerator, so that it can be called before we create the LTOCodeGenerator.

Now we can either 
   (1) modify the signature of the lto_codegen_debug_options and lto_codegen_debug_options_array API functions 
or (2) add new API functions.

I prefer (1) because as it is now, the API is broken.
I uploaded a patch here https://reviews.llvm.org/D92611

Any feedback is appreciated. Thank you

Wael



More information about the llvm-dev mailing list