[llvm] [SandboxIR] Add callbacks for instruction insert/remove/move ops (PR #112965)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 26 17:32:26 PDT 2024
================
@@ -660,4 +663,53 @@ Module *Context::createModule(llvm::Module *LLVMM) {
return M;
}
+void Context::runEraseInstrCallbacks(Instruction *I) {
+ for (const auto &CBEntry : EraseInstrCallbacks)
+ CBEntry.second(I);
+}
+
+void Context::runCreateInstrCallbacks(Instruction *I) {
+ for (auto &CBEntry : CreateInstrCallbacks)
+ CBEntry.second(I);
+}
+
+void Context::runMoveInstrCallbacks(Instruction *I, const BBIterator &WhereIt) {
+ for (auto &CBEntry : MoveInstrCallbacks)
+ CBEntry.second(I, WhereIt);
+}
+
+Context::CallbackID Context::registerEraseInstrCallback(EraseInstrCallback CB) {
+ CallbackID ID = NextCallbackID++;
+ EraseInstrCallbacks[ID] = CB;
----------------
vporpo wrote:
How about an assertion on `EraseInstrCallbacks.size()` checking that it's smaller than say 16 ? It could help catch issues where you keep on registering callbacks by mistake.
https://github.com/llvm/llvm-project/pull/112965
More information about the llvm-commits
mailing list