[PATCH] D29445: LTO: add a code-model flag

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 17:59:21 PST 2017


pcc added a comment.

In https://reviews.llvm.org/D29445#670256, @martell wrote:

> > I don't think the code model information will be passed correctly from the compiler to the linker in that case. `CMModel` will be the value of the existing `-code-model` flag, which will be `CodeModel::Default` by default (same as the default in `lto::Config`, see http://llvm-cs.pcc.me.uk/include/llvm/CodeGen/CommandFlags.h#81). You can pass it to lld with (e.g.) `-mllvm -code-model=large` or to gold with `-plugin-opt -code-model=large`.
>
> I think I am missing something here. How does `Config->CodeModel = CMModel;` get all the way into the gold plugin for parsing.  I had to add an option to `process_plugin_option` to pull out the string.


In the gold plugin any options that the plugin does not recognize are passed through to `cl::ParseCommandLineOptions`, see http://llvm-cs.pcc.me.uk/tools/gold/gold-plugin.cpp#234

> Is there something within `cl::opt` that has the magic to check the string against CMModel?

Yes, any `cl::opt`s of enum type are checked during `ParseCommandLineOptions`. The command line library will produce an error message if the option string does not match any of the enumerators.


Repository:
  rL LLVM

https://reviews.llvm.org/D29445





More information about the llvm-commits mailing list