[LLVMdev] [RFC][CodeGen] What CLI should we provide for overriding the target decision on whether to run a pass (GlobalMerge) ?

Ahmed Bougacha ahmed.bougacha at gmail.com
Fri Apr 10 11:54:37 PDT 2015


Hi Eric, all,

Currently, there isn't a good way to force enable/disable GlobalMerge.

Targets decide whether to create the pass based on the optimization
level (which is how it should be).

The problem is when you want to override that decision.  We have
-enable-global-merge, true by default, which should really be
-disable-global-merge, as it only works as a last-resort way to
force-disable it (i.e., if the target decided it won't add the pass,
-enable-global-merge does nothing).

I had some patches for LTO up, but let's forget about that and just
worry about command-line options for now.

I see a few solutions, ordered by decreasing ugliness:
- move the CodeGenOpt check to the pass rather than each target
- have targets tell the pass whether they want it enabled by default
(a bool ctor parameter), so the one cl::opt flag can properly override
that
- add -arm-/-aarch64-global-merge flags, that override the CodeGenOpt
default;  teach clang to generate those from -m[no-]global-merge
- do exactly the same thing as BranchFolding/-enable-tail-merge: make
the pass a default part of the codegen pipeline, add a flag to
TargetPassConfig, have targets set the default

I really like the last one, and I haven't seen any FIXME or anything
suggesting it's problematic w.r.t. long-term plans for
LTO/per-function codegen.  The target then looks at the flag, and at
the PassConfig gotten from the MachineFunction, and decides whether to
run.

Thoughts?

-Ahmed



More information about the llvm-dev mailing list