[llvm] [MIR] Fix vreg flag vector memory leak (PR #112479)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 23:58:18 PDT 2024
https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/112479
>From c1690d0c48792980f36ff3d08383f86842ef2bd4 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Tue, 15 Oct 2024 16:49:32 +0000
Subject: [PATCH 1/2] [MIR] Fix vreg flag vector memory leak
SmallVector allocates on stack so that works out here.
---
llvm/include/llvm/CodeGen/MIRParser/MIParser.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/CodeGen/MIRParser/MIParser.h b/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
index 4d93213de5e070..ea4ba488c9295b 100644
--- a/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
+++ b/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
@@ -45,7 +45,7 @@ struct VRegInfo {
} D;
Register VReg;
Register PreferredReg;
- std::vector<uint8_t> Flags;
+ SmallVector<uint8_t> Flags;
};
using Name2RegClassMap = StringMap<const TargetRegisterClass *>;
>From 7d8bf5125a2e1d69f18b04cddd085093f0038c23 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 16 Oct 2024 06:57:34 +0000
Subject: [PATCH 2/2] Change to bit field
---
llvm/include/llvm/CodeGen/MIRParser/MIParser.h | 2 +-
llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MIRParser/MIParser.h b/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
index ea4ba488c9295b..0f2898d3554d06 100644
--- a/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
+++ b/llvm/include/llvm/CodeGen/MIRParser/MIParser.h
@@ -45,7 +45,7 @@ struct VRegInfo {
} D;
Register VReg;
Register PreferredReg;
- SmallVector<uint8_t> Flags;
+ uint8_t Flags = 0;
};
using Name2RegClassMap = StringMap<const TargetRegisterClass *>;
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 10d3cdcf0c1ce1..c0c61b3fdd1677 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -703,7 +703,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
return error(FlagStringValue.SourceRange.Start,
Twine("use of undefined register flag '") +
FlagStringValue.Value + "'");
- Info.Flags.push_back(FlagValue);
+ Info.Flags |= FlagValue;
}
RegInfo.noteNewVirtualRegister(Info.VReg);
}
More information about the llvm-commits
mailing list