Per title, we used to pass -mno-global-merge when specified, and enable GlobalMerge always (leaving it to LLVM to decide whether to actually enable it: it does, on ARM and AArch64, for -O1 and above).
This addresses two problems (I'm fine with splitting the patch if desired):
- with LTO, passing -mno-global-merge didn't do anything, since LTO implies -O3 from the backend's standpoint.
- GlobalMerge was enabled by -O1. Instead, on AArch64, enable it at -O3, or when -mglobal-merge is specified. (the goal is to have it predicated by -O3 on ARM as well, but I still need to measure before doing that.)
Now, -mglobal-merge and -mno-global-merge are both explicitly passed by the driver.
They are then passed to the backend using module flag metadata (bikeshedding time: name is prose, and value is string. We can change both, and AFAICT there's no similar backend flag to be consistent with, yet.)
Thanks!
-Ahmed
Do you need to pass LLVMContext here? I saw a build error when I applied this patch.