[PATCH] D52127: [MF][MBB]: Add the ability to register callbacks for removal and insertion of MachineInstrs

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 17 20:54:31 PDT 2018


aditya_nandakumar added a comment.

In https://reviews.llvm.org/D52127#1237084, @MatzeB wrote:

> I've seen callbacks lead to unintuitive/hard to understand code. Can you motivate the use case some more?


One of the motivations was the above - guaranteeing that the legalizer will always legalize intermediate instructions - right now it only guarantees legalization when the intermediate instructions are created with the MachineIRBuilder that's passed in - it would be nice to not rely on that mechanism. Besides insertions, it would be nice to keep track of instruction deletions -for eg in the combiner - it's useful to know which instructions were erased and needs to be removed the various worklists rather than conservatively assuming that the current instruction is always considered erased even if it isn't. Additionally if a combine deletes any other instruction besides the current root, we will currently not know about this and will result in calling combine(MI) on a deleted instruction resulting in UB (same in the legalizer).
Lastly I think this mechanism will allow a CSEing builder to also keep track of new instructions(again without relying on usage of MIRBuilder) as well as deletions (currently very hard).


Repository:
  rL LLVM

https://reviews.llvm.org/D52127





More information about the llvm-commits mailing list