[llvm] [CodeGen] Fix ponential memory leak in CodeGenPassBuilderTest (PR #77864)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 11 18:49:20 PST 2024
https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/77864
None
>From 70300289571c14606d12610f4eac859f43c3c9d0 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Fri, 12 Jan 2024 10:48:39 +0800
Subject: [PATCH] [CodeGen] Fix ponential memory leak in CodeGenPassBuilderTest
---
llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp b/llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp
index 9be3616cd362b5..3d852f40f137dc 100644
--- a/llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp
+++ b/llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp
@@ -46,7 +46,7 @@ class DummyCodeGenPassBuilder
class CodeGenPassBuilderTest : public testing::Test {
public:
- LLVMTargetMachine *TM;
+ std::unique_ptr<LLVMTargetMachine> TM;
static void SetUpTestCase() {
InitializeAllTargets();
@@ -69,8 +69,8 @@ class CodeGenPassBuilderTest : public testing::Test {
GTEST_SKIP();
TargetOptions Options;
- TM = static_cast<LLVMTargetMachine *>(
- TheTarget->createTargetMachine("", "", "", Options, std::nullopt));
+ TM = std::unique_ptr<LLVMTargetMachine>(static_cast<LLVMTargetMachine *>(
+ TheTarget->createTargetMachine("", "", "", Options, std::nullopt)));
if (!TM)
GTEST_SKIP();
}
@@ -85,7 +85,7 @@ TEST_F(CodeGenPassBuilderTest, basic) {
PassInstrumentationCallbacks PIC;
DummyCodeGenPassBuilder CGPB(*TM, getCGPassBuilderOption(), &PIC);
PipelineTuningOptions PTO;
- PassBuilder PB(TM, PTO, std::nullopt, &PIC);
+ PassBuilder PB(TM.get(), PTO, std::nullopt, &PIC);
PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
More information about the llvm-commits
mailing list