[llvm] [SandboxVec] Notify scheduler about new instructions (PR #115102)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 12:01:07 PST 2024


================
@@ -24,6 +25,8 @@ class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
   AAResults *AA = nullptr;
   ScalarEvolution *SE = nullptr;
 
+  std::unique_ptr<sandboxir::Context> Ctx;
----------------
vporpo wrote:

I think it does need to be a member, here is why:
If we create the Context within the scope of `runImpl()`, like we used to, then `Ctx` goes out of scope once we return from `runImpl()`, but the problem is that the nested members of the `SandboxVectorizerPass`, like the Scheduler, get destroyed after the scope goes out of scope. This means that if we try to unregister the scheduler's callbacks within the Scheduler destructor we access freed memory.

Not sure how else we could fix this in a clean way. Having a member context seems to be the easiest fix.

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


More information about the llvm-commits mailing list