-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SLPVectorizer] Clear TreeEntryToStridedPtrInfoMap
.
#160544
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-backend-risc-v @llvm/pr-subscribers-llvm-transforms Author: Mikhail Gudim (mgudim) ChangesWe need to clear Full diff: https://github.com/llvm/llvm-project/pull/160544.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1814d9a6811c0..39530e92e692d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2099,6 +2099,7 @@ class BoUpSLP {
UserIgnoreList = nullptr;
PostponedGathers.clear();
ValueToGatherNodes.clear();
+ TreeEntryToStridedPtrInfoMap.clear();
}
unsigned getTreeSize() const { return VectorizableTree.size(); }
|
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.
The test is required. Or revert the original commit and fix it there
What kind of test should it be? Reverting seems more complicated because several other merged commits were based on this one. |
The one that reveals the issue with not clearing the map |
The issue would be revealed only if we use the same BoUpSLP and when building a tree some memory is reused for a TreeNode. I don't see a way to set this up except a unit test and even that would be non-trivial. There is no test for any of lines is Should I start a new test in |
Up to you, it can be a unittest or a lit test, that crashes for you. |
Would it be ok that in a different commit I'll add asserts in "buildTree" that make sure everything from |
Ok, but still need a test |
Why do we need a test if we have asserts? Don't asserts make it self-evident that the map is cleared? The test would essentially be the same this as an assert, just much more effort to set up. |
Each non-nfc patch requires a test |
I am out of ideas. I don't see how to add asserts to the code so it doesn't look stupid. Current code is like this: "buildTree(...) {
I thought that maybe I can set up a unit test. There is no public header to include which would contain Constructing test by hand to try to make SLP crash is very hard. There won't be a memory leak because the map gets deleted automatically with I can measure the size of BoUpSLP object right after it's created and right after deleteTree and assert that they are equal. Test would check that the assert is not hit. Will this be acceptable? Can you suggest something else? |
Is this an official rule written somewhere? I'm pretty sure that any reasonable guidelines would allow merging something like this without a test. |
ping |
Just add a test that crahes |
I can't come up with a test that crashes |
Simple test that crashes with the assertion but without clearing the map |
sorry, I don't understand what you mean. If I add an assertion somewhere that map is not cleared, it will break llvm for everyone until the commit which clears the map is merged |
I understand it. Just add a new test, that will crash with assertion but without clearing. |
Is this what you mean: |
✅ With the latest revision this PR passed the C/C++ code formatter. |
@@ -0,0 +1,74 @@ | |||
; RUN: opt -S --passes=slp-vectorizer < %s | FileCheck %s | |||
|
|||
; CHECK-NOT: TreeEntryToStridedPtrInfoMap is not cleared |
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.
Add real checks here
We need to clear `TreeEntryToStridedPtrInfoMap` in `deleteTree`.
We need to clear `TreeEntryToStridedPtrInfoMap` in `deleteTree`.
We need to clear
TreeEntryToStridedPtrInfoMap
indeleteTree
.