In order to enable LTO with GlobalISel, we need to be able to select between
GlobalISel and SDISel via some mechanism in the bitcode. Usually these kinds
of codegen options are done with function attributes and passes will inspect
these at link-time compilation to decide what to do. However, when that decision
involves changing the pass pipeline itself this model breaks down. We can't
change the pass pipeline once it's been set up on a per-function basis.
This patch adds a unified ISel pipeline that's opt-in for targets, and enabled
for AArch64 only at the moment. It basically just schedules the GlobalISel
passes before SelectionDAG selection, much like the fallback mechanism. However,
it uses a different query to decide whether or not to run the GlobalISel passes
at all (rather than the FailedISel MF property).
Each GlobalISel pass needs to be taught to *not* run unless the TargetMachine
indicates that GlobalISel was enabled, or if there's a "use-globalisel" function
attribute present.
There are a few things that break when doing this.
- MachineDominator construction seems to crash when it's given a function which
doesn't have any blocks, which happens when it tries to run right after the
IRTranslator which bails out immediately. This is worked around by just creating
an empty block temporarily.
- llc's handy -run-pass testing option breaks unless we somehow know in the pass
that's being run that we have been specifically requested. Some module metadata
is added to communicate to the passes in question that they need to run.
clang-format: please reformat the code