-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fixing memory leaks in tests #161878
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
Fixing memory leaks in tests #161878
Conversation
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-mlgo Author: S. VenkataKeerthy (svkeerthy) ChangesFixing the memory leaks introduced (#158376) in the unit tests of FunctionPropertiesAnalysis and IR2Vec. Full diff: https://github.com/llvm/llvm-project/pull/161878.diff 2 Files Affected:
diff --git a/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
index b6e8567ee514d..0ae6d7c1e31af 100644
--- a/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
@@ -47,7 +47,7 @@ class FunctionPropertiesAnalysisTest : public testing::Test {
return IR2VecVocabAnalysis(std::move(VocabVector));
});
IR2VecVocab =
- new ir2vec::Vocabulary(ir2vec::Vocabulary::createDummyVocabForTest(1));
+ std::make_unique<ir2vec::Vocabulary>(ir2vec::Vocabulary::createDummyVocabForTest(1));
MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
FAM.registerPass([&] { return DominatorTreeAnalysis(); });
@@ -69,7 +69,7 @@ class FunctionPropertiesAnalysisTest : public testing::Test {
std::unique_ptr<LoopInfo> LI;
FunctionAnalysisManager FAM;
ModuleAnalysisManager MAM;
- ir2vec::Vocabulary *IR2VecVocab;
+ std::unique_ptr<ir2vec::Vocabulary> IR2VecVocab;
void TearDown() override {
// Restore original IR2Vec weights
diff --git a/llvm/unittests/Analysis/IR2VecTest.cpp b/llvm/unittests/Analysis/IR2VecTest.cpp
index 743628fffac76..d136cb6a316b1 100644
--- a/llvm/unittests/Analysis/IR2VecTest.cpp
+++ b/llvm/unittests/Analysis/IR2VecTest.cpp
@@ -295,7 +295,7 @@ TEST(IR2VecTest, ZeroDimensionEmbedding) {
// Fixture for IR2Vec tests requiring IR setup.
class IR2VecTestFixture : public ::testing::Test {
protected:
- Vocabulary *V;
+ std::unique_ptr<Vocabulary> V;
LLVMContext Ctx;
std::unique_ptr<Module> M;
Function *F = nullptr;
@@ -304,7 +304,7 @@ class IR2VecTestFixture : public ::testing::Test {
Instruction *RetInst = nullptr;
void SetUp() override {
- V = new Vocabulary(Vocabulary::createDummyVocabForTest(2));
+ V = std::make_unique<Vocabulary>(Vocabulary::createDummyVocabForTest(2));
// Setup IR
M = std::make_unique<Module>("TestM", Ctx);
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
alinas
left a comment
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.
LG
Fixing the memory leaks introduced (#158376) in the unit tests of FunctionPropertiesAnalysis and IR2Vec.