[llvm] [SandboxIR] Add callbacks for instruction insert/remove/move ops. (PR #112965)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 14:00:24 PDT 2024


================
@@ -48,6 +64,21 @@ class Context {
   /// Type objects.
   DenseMap<llvm::Type *, std::unique_ptr<Type, TypeDeleter>> LLVMTypeToTypeMap;
 
+  /// Callbacks called when an IR instruction is about to get removed. Keys are
+  /// used as IDs for deregistration.
+  DenseMap<CallbackID, RemoveInstrCallback> RemoveInstrCallbacks;
+  /// Callbacks called when an IR instruction is about to get inserted. Keys are
+  /// used as IDs for deregistration.
+  DenseMap<CallbackID, InsertInstrCallback> InsertInstrCallbacks;
+  /// Callbacks called when an IR instruction is about to get moved. Keys are
+  /// used as IDs for deregistration.
+  DenseMap<CallbackID, MoveInstrCallback> MoveInstrCallbacks;
+
+  /// A counter used for assigning callback IDs during registration. The same
+  /// counter is used for all kinds of callbacks so we can detect mismatched
+  /// registration/deregistration.
+  static CallbackID NextCallbackID;
----------------
aeubanks wrote:

this shouldn't be static?

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


More information about the llvm-commits mailing list