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

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 20 13:35:27 PDT 2018


MatzeB accepted this revision.
MatzeB added a comment.
This revision is now accepted and ready to land.

LGTM with nitpicks addressed.



================
Comment at: include/llvm/CodeGen/MachineFunction.h:372-373
+    virtual ~Delegate() = default;
+    virtual void MF_HandleInsertion(const MachineInstr *MI) = 0;
+    virtual void MF_HandleRemoval(const MachineInstr *MI) = 0;
+  };
----------------
Use `const MachineInstr&` here to make it obvious that the parameters cannot be `nullptr`. (We didn't do that in older APIs but I think we should do it for new APIs we create).


================
Comment at: include/llvm/CodeGen/MachineFunction.h:380-381
+  // Callbacks for insertion and removal.
+  void handleInsertion(const MachineInstr *MI);
+  void handleRemoval(const MachineInstr *MI);
+  friend struct ilist_traits<MachineInstr>;
----------------
should also use references.


================
Comment at: include/llvm/CodeGen/MachineFunction.h:401
 
+  void resetDelegate(Delegate *delegate) {
+    // Ensure another delegate does not take over unless the current
----------------
Add doxygen comment to public API.


================
Comment at: include/llvm/CodeGen/MachineFunction.h:410
+
+  void setDelegate(Delegate *delegate) {
+    assert(delegate && !TheDelegate &&
----------------
Add a doxygen comment.


https://reviews.llvm.org/D52127





More information about the llvm-commits mailing list