[RFC] Passing target module flag with LTO enabled

Hi,

We would like to implement -msmall-data-limit= flag for RISC-V target. The flag will set the small data limitation for global and static variables. If the data is equal or smaller than the limitation, it will put into the small data section. But the flag will be no effect when the LTO enabled. The patch is under review[1].

One possible solution is passing target flag through the LTO plugin interface, the other could be storing the flag in IR and then read by the backend. Given that the flag influences the global variables, Eli pointed out that it should not be a function flag. Arm and AArch64 have a similar flag -mglobal-merge which will influence global variables. The relative patch[2] store the flag as a module metadata to pass through LTO.

We’d like to get your feedback, in how to pass through the flag.

  1. LTO interface
  2. Module metadata
  3. Other way represented in IR?

Thanks,
Shiva

References
[1] [RISCV] Passing small data limitation value to RISCV backend https://reviews.llvm.org/D57497
[2] Pass -mglobal-merge as a module flag metadata. https://reviews.llvm.org/D7968