<div dir="ltr">I replied to the current patch you committed, but the only idea I have otherwise is to make this programmatically possible via either a struct that's passed down to the TargetMachine creation (something off of TargetOptions ala the abi bits I put there, but target specific), or Akira had an idea at one point of passing the options via strings to the backend. I'm less fond of this, but it is, admittedly, more flexible when versions differ.<br><div><br></div><div>Thoughts?</div><div><br></div><div>-eric</div></div><br><div class="gmail_quote">On Sat, Apr 11, 2015 at 12:48 AM Ahmed Bougacha <<a href="mailto:ahmed.bougacha@gmail.com">ahmed.bougacha@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And of course last option isn't possible, because (for now) we need to<br>
pass the maximum offset to createGlobalMergePass.  This isn't a<br>
fundamental limitation though (it used to be given through TLI, with<br>
D8070 and some callbacks we can fix that), so I'm curious about<br>
peoples opinions, if any.<br>
<br>
Looking at this again, the other options are really pretty terrible,<br>
so the only realistic choice is the target-specific flags.<br>
I expect this to change with the proper LTO support. The last<br>
iteration of D7968 was a proposal for adding target-specific<br>
attributes to globals.<br>
<br>
Anyway, sorry for the noise, there wasn't much room for comments after<br>
all.  If you can think of a better solution I'd love to hear it!<br>
<br>
-Ahmed<br>
<br>
On Fri, Apr 10, 2015 at 11:54 AM, Ahmed Bougacha<br>
<<a href="mailto:ahmed.bougacha@gmail.com" target="_blank">ahmed.bougacha@gmail.com</a>> wrote:<br>
> Hi Eric, all,<br>
><br>
> Currently, there isn't a good way to force enable/disable GlobalMerge.<br>
><br>
> Targets decide whether to create the pass based on the optimization<br>
> level (which is how it should be).<br>
><br>
> The problem is when you want to override that decision.  We have<br>
> -enable-global-merge, true by default, which should really be<br>
> -disable-global-merge, as it only works as a last-resort way to<br>
> force-disable it (i.e., if the target decided it won't add the pass,<br>
> -enable-global-merge does nothing).<br>
><br>
> I had some patches for LTO up, but let's forget about that and just<br>
> worry about command-line options for now.<br>
><br>
> I see a few solutions, ordered by decreasing ugliness:<br>
> - move the CodeGenOpt check to the pass rather than each target<br>
> - have targets tell the pass whether they want it enabled by default<br>
> (a bool ctor parameter), so the one cl::opt flag can properly override<br>
> that<br>
> - add -arm-/-aarch64-global-merge flags, that override the CodeGenOpt<br>
> default;  teach clang to generate those from -m[no-]global-merge<br>
> - do exactly the same thing as BranchFolding/-enable-tail-merge: make<br>
> the pass a default part of the codegen pipeline, add a flag to<br>
> TargetPassConfig, have targets set the default<br>
><br>
> I really like the last one, and I haven't seen any FIXME or anything<br>
> suggesting it's problematic w.r.t. long-term plans for<br>
> LTO/per-function codegen.  The target then looks at the flag, and at<br>
> the PassConfig gotten from the MachineFunction, and decides whether to<br>
> run.<br>
><br>
> Thoughts?<br>
><br>
> -Ahmed<br>
</blockquote></div>