Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c956500

Browse files
committed
Store the global variable that's created so that it's reclaimed afterwards.
This plugs a memory leak in ARM's FastISel by storing the GV in Module so that it's reclaimed. PR17978 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198160 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 827176c commit c956500

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Target/ARM/ARMFastISel.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ARMFastISel : public FastISel {
7777

7878
/// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
7979
/// make the right decision when generating code for different targets.
80+
Module &M;
8081
const ARMSubtarget *Subtarget;
8182
const TargetMachine &TM;
8283
const TargetInstrInfo &TII;
@@ -91,6 +92,7 @@ class ARMFastISel : public FastISel {
9192
explicit ARMFastISel(FunctionLoweringInfo &funcInfo,
9293
const TargetLibraryInfo *libInfo)
9394
: FastISel(funcInfo, libInfo),
95+
M(const_cast<Module&>(*funcInfo.Fn->getParent())),
9496
TM(funcInfo.MF->getTarget()),
9597
TII(*TM.getInstrInfo()),
9698
TLI(*TM.getTargetLowering()) {
@@ -2244,7 +2246,7 @@ unsigned ARMFastISel::getLibcallReg(const Twine &Name) {
22442246
EVT LCREVT = TLI.getValueType(GVTy);
22452247
if (!LCREVT.isSimple()) return 0;
22462248

2247-
GlobalValue *GV = new GlobalVariable(Type::getInt32Ty(*Context), false,
2249+
GlobalValue *GV = new GlobalVariable(M, Type::getInt32Ty(*Context), false,
22482250
GlobalValue::ExternalLinkage, 0, Name);
22492251
assert(GV->getType() == GVTy && "We miscomputed the type for the global!");
22502252
return ARMMaterializeGV(GV, LCREVT.getSimpleVT());

0 commit comments

Comments
 (0)