[PATCH] D52947: [globalisel][combiner] Make the CombinerChangeObserver a MachineFunction::Delegate

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 5 14:17:02 PDT 2018


dsanders created this revision.
dsanders added reviewers: aditya_nandakumar, bogner, volkan, rtereshin.
Herald added subscribers: kristof.beyls, rovka.
Herald added a reviewer: javed.absar.

This allows us to register it with the MachineFunction delegate and be
notified automatically about erasure and creation of instructions. However,
we still need explicit notification for modifications such as those caused
by setReg() or replaceRegWith().

There is a catch with this though. The notification for creation is
delivered before any operands can be added. While appropriate for
scheduling combiner work. This is unfortunate for debug output since an
opcode by itself doesn't provide sufficient information on what happened.
As a result, the work list remembers the instructions (when debug output is
requested) and emits a more complete dump later.

Another nit is that the MachineFunction::Delegate provides const pointers
which is inconvenient since we want to use it to schedule future
modification. To resolve this GISelWorkList now has an optional pointer to
the MachineFunction which describes the scope of the work it is permitted
to schedule. If a given MachineInstr* is in this function then it is
permitted to schedule work to be performed on the MachineInstr's. An
alternative to this would be to remove the const from the
MachineFunction::Delegate interface, however delegates are not permitted
to modify the MachineInstr's they receive.

In addition to this, the observer has three interface changes.

- erasedInstr() is now erasingInstr() to indicate it is about to be erased but still exists at the moment.
- changingInstr() and changedInstr() have been added to report changes before and after they are made. This allows us to trace the changes in the debug output.
- As a convenience changingAllUsesOfReg() and finishedChangingAllUsesOfReg() will report changingInstr() and changedInstr() for each use of a given register. This is primarily useful for changes caused by MachineRegisterInfo::replaceRegWith()

With this in place, both combine rules have been updated to report their
changes to the observer.

Finally, make some cosmetic changes to the debug output and make Combiner
and CombinerHelp


Repository:
  rL LLVM

https://reviews.llvm.org/D52947

Files:
  include/llvm/CodeGen/GlobalISel/Combiner.h
  include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  include/llvm/CodeGen/GlobalISel/CombinerInfo.h
  include/llvm/CodeGen/GlobalISel/GISelWorkList.h
  lib/CodeGen/GlobalISel/Combiner.cpp
  lib/CodeGen/GlobalISel/CombinerHelper.cpp
  lib/CodeGen/GlobalISel/Legalizer.cpp
  test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-extending-loads-cornercases.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52947.168532.patch
Type: text/x-patch
Size: 18577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181005/286328f8/attachment-0001.bin>


More information about the llvm-commits mailing list