[llvm] [SandboxVec][BottomUpVec] Fix ownership of Legality (PR #143018)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 12:21:13 PDT 2025


================
@@ -498,9 +498,10 @@ bool BottomUpVec::runOnRegion(Region &Rgn, const Analyses &A) {
   assert(SeedSlice.size() >= 2 && "Bad slice!");
   Function &F = *SeedSlice[0]->getParent()->getParent();
   IMaps = std::make_unique<InstrMaps>();
-  Legality = std::make_unique<LegalityAnalysis>(
+  auto LegalityPtr = std::make_unique<LegalityAnalysis>(
       A.getAA(), A.getScalarEvolution(), F.getParent()->getDataLayout(),
       F.getContext(), *IMaps);
+  Legality = LegalityPtr.get();
----------------
vporpo wrote:

Yes it will become a dangling pointer, but by design all its uses are within the scope of `BottomUpVec::runOnRegion()`.

Hmm I guess I could pass it in as an argument, I don't see too many places where it's being used, let me check.

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


More information about the llvm-commits mailing list