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

Jorge Gorbe Moya via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 18:20:16 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;
----------------
slackito wrote:

Done. I'm not super happy with having an arbitrary limit like this not documented anywhere and with a kinda low value, but it will be useful while we're developing the vectorizer and we can always revisit this decision later.

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


More information about the llvm-commits mailing list