-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC] Fix memory leak in IR2Vec tests #161964
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
After refactoring in ed1d954, VocabStorage are being leaked.
@llvm/pr-subscribers-mlgo @llvm/pr-subscribers-llvm-analysis Author: Jinsong Ji (jsji) ChangesAfter refactoring in ed1d954, VocabStorage are being leaked. Full diff: https://github.com/llvm/llvm-project/pull/161964.diff 2 Files Affected:
diff --git a/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
index 497da8f3fc70b..ec1e848f943be 100644
--- a/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
@@ -59,6 +59,11 @@ class FunctionPropertiesAnalysisTest : public testing::Test {
ir2vec::ArgWeight = 1.0;
}
+ ~FunctionPropertiesAnalysisTest() override {
+ delete IR2VecVocab;
+ IR2VecVocab = nullptr;
+ }
+
private:
float OriginalOpcWeight = ir2vec::OpcWeight;
float OriginalTypeWeight = ir2vec::TypeWeight;
diff --git a/llvm/unittests/Analysis/IR2VecTest.cpp b/llvm/unittests/Analysis/IR2VecTest.cpp
index d136cb6a316b1..4348d5cee106a 100644
--- a/llvm/unittests/Analysis/IR2VecTest.cpp
+++ b/llvm/unittests/Analysis/IR2VecTest.cpp
@@ -319,6 +319,10 @@ class IR2VecTestFixture : public ::testing::Test {
AddInst = BinaryOperator::CreateAdd(Arg, Const, "add", BB);
RetInst = ReturnInst::Create(Ctx, AddInst, BB);
}
+ void TearDown() override {
+ delete V ;
+ V = nullptr;
+ }
};
TEST_F(IR2VecTestFixture, GetInstVecMap_Symbolic) {
|
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.
Pull Request Overview
This PR fixes memory leaks in IR2Vec unit tests by adding proper cleanup of VocabStorage objects that were being leaked after a previous refactoring (ed1d954).
- Added TearDown method to IR2VecTestFixture to delete the V pointer and set it to nullptr
- Added destructor to FunctionPropertiesAnalysisTest to delete IR2VecVocab pointer and set it to nullptr
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
llvm/unittests/Analysis/IR2VecTest.cpp | Added TearDown method to properly cleanup VocabStorage pointer V |
llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp | Added destructor to properly cleanup IR2VecVocab pointer |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
#161878 should have already fixed this? |
After refactoring in ed1d954, VocabStorage are being leaked.