[llvm] [CodeGen] Add listener support to the rematerializer (NFC) (PR #184338)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 07:35:38 PST 2026


================
@@ -186,6 +186,37 @@ class Rematerializer {
     friend Rematerializer;
   };
 
+  /// Rematerializer listener. Defines overridable hooks that allow to catch
+  /// specific events inside the rematerializer. All hooks do nothing by
+  /// default. Listeners can be added or removed at any time during the
+  /// rematerializer's lifetime.
+  class Listener {
+  private:
----------------
lucas-rami wrote:

My rationale for making them private was that only the Rematerializer should call those since they are supposed to catch Rematerializer-triggered events, (the Rematerializer is a friend class for this reason). Specific listeners can then define public methods to e.g., batch process recorded changes (see #184341 for example). 

https://github.com/llvm/llvm-project/pull/184338


More information about the llvm-commits mailing list