-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SandboxVec][BottomUpVec] Fix ownership of Legality #143018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-vectorizers Author: vporpo (vporpo) ChangesFix the ownership of Full diff: https://github.com/llvm/llvm-project/pull/143018.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index af0e07de4f51f..7b5c6b1b7e339 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -34,7 +34,7 @@ namespace llvm::sandboxir {
/// transaction, depending on the cost.
class BottomUpVec final : public RegionPass {
bool Change = false;
- std::unique_ptr<LegalityAnalysis> Legality;
+ LegalityAnalysis *Legality = nullptr;
/// The original instructions that are potentially dead after vectorization.
DenseSet<Instruction *> DeadInstrCandidates;
/// Maps scalars to vectors.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index 9781d4cf146ef..bf28a7898c0d2 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -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();
// TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
SmallVector<Value *> SeedSliceVals(SeedSlice.begin(), SeedSlice.end());
|
|
@llvm/pr-subscribers-llvm-transforms Author: vporpo (vporpo) ChangesFix the ownership of Full diff: https://github.com/llvm/llvm-project/pull/143018.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index af0e07de4f51f..7b5c6b1b7e339 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -34,7 +34,7 @@ namespace llvm::sandboxir {
/// transaction, depending on the cost.
class BottomUpVec final : public RegionPass {
bool Change = false;
- std::unique_ptr<LegalityAnalysis> Legality;
+ LegalityAnalysis *Legality = nullptr;
/// The original instructions that are potentially dead after vectorization.
DenseSet<Instruction *> DeadInstrCandidates;
/// Maps scalars to vectors.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index 9781d4cf146ef..bf28a7898c0d2 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -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();
// TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
SmallVector<Value *> SeedSliceVals(SeedSlice.begin(), SeedSlice.end());
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the Legality member become a dangling pointer after the function returns and LegalityPtr is destroyed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Fix the ownership of `Legality` member variable of BottomUpVec. It should get created in runOnFunction() and get destroyed when the function returns.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/15035 Here is the relevant piece of the build log for the reference |
Fix the ownership of `Legality` member variable of BottomUpVec. It should get created in runOnFunction() and get destroyed when the function returns.
Fix the ownership of
Legalitymember variable of BottomUpVec. It should get created in runOnFunction() and get destroyed when the function returns.