[llvm] [RFC][IR] InstructionListener: per-function instruction removal/RAUW notifications (PR #193198)

Pankaj Dwivedi via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 01:28:44 PDT 2026


================
@@ -112,6 +114,29 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
 
   friend class SymbolTableListTraits<Function>;
 
+  friend class InstructionListener;
+  SmallVector<InstructionListener *, 0> InstructionListeners;
+
+  void addInstructionListener(InstructionListener *L);
+  void removeInstructionListener(InstructionListener *L);
+
+public:
+  bool hasInstructionListeners() const { return !InstructionListeners.empty(); }
+
+  void notifyInstructionRemoved(Instruction *I) {
+    if (hasInstructionListeners())
+      notifyInstructionRemovedImpl(I);
+  }
+
+  void notifyInstructionRAUW(Instruction *Old, Value *New) {
----------------
PankajDwivedi-25 wrote:

sure, thanks.

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


More information about the llvm-commits mailing list