[PATCH] D79769: [GlobalISel] Create an opt-in unified GlobalISel + SelectionDAG pipeline.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 00:30:16 PDT 2020


aemerson created this revision.
aemerson added reviewers: paquette, kristof.beyls, qcolombet, dsanders, eli.friedman.
aemerson added a project: LLVM.
Herald added subscribers: dexonsmith, hiraditya, rovka.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79769

Files:
  llvm/include/llvm/CodeGen/TargetPassConfig.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
  llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
  llvm/lib/CodeGen/GlobalISel/Localizer.cpp
  llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
  llvm/lib/CodeGen/GlobalISel/Utils.cpp
  llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.h
  llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option-fastisel.ll
  llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
  llvm/test/CodeGen/AArch64/GlobalISel/use-globalisel-fn-attr.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/max-jump-table.ll
  llvm/test/CodeGen/AArch64/min-jump-table.ll
  llvm/test/CodeGen/AArch64/multi-vector-store-size.ll
  llvm/tools/llc/llc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79769.263364.patch
Type: text/x-patch
Size: 24443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200512/e3e21d6c/attachment.bin>


More information about the llvm-commits mailing list