mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-24 03:25:00 +00:00
Trying to fix Mangler memory leak in TargetLoweringObjectFile.
Summary: `TargetLoweringObjectFile` can be re-used and thus `TargetLoweringObjectFile::Initialize()` can be called multiple times causing `Mang` pointer memory leak. Reviewers: echristo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D24659 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281718 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
793f0085f9
commit
6c1574bca5
@ -38,7 +38,7 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
|
||||
MCContext *Ctx;
|
||||
|
||||
/// Name-mangler for global names.
|
||||
Mangler *Mang;
|
||||
Mangler *Mang = nullptr;
|
||||
|
||||
TargetLoweringObjectFile(
|
||||
const TargetLoweringObjectFile&) = delete;
|
||||
|
@ -43,6 +43,8 @@ using namespace llvm;
|
||||
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
|
||||
const TargetMachine &TM) {
|
||||
Ctx = &ctx;
|
||||
// `Initialize` can be called more than once.
|
||||
if (Mang != nullptr) delete Mang;
|
||||
Mang = new Mangler();
|
||||
InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(),
|
||||
TM.getCodeModel(), *Ctx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user