mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
Plug a memory leak in the GCOV profiling emitter, which never released the edge table memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168259 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -540,13 +540,13 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(
|
|||||||
// read it. Threads and invoke make this untrue.
|
// read it. Threads and invoke make this untrue.
|
||||||
|
|
||||||
// emit [(succs * preds) x i64*], logically [succ x [pred x i64*]].
|
// emit [(succs * preds) x i64*], logically [succ x [pred x i64*]].
|
||||||
|
size_t TableSize = Succs.size() * Preds.size();
|
||||||
Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx);
|
Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx);
|
||||||
ArrayType *EdgeTableTy = ArrayType::get(
|
ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize);
|
||||||
Int64PtrTy, Succs.size() * Preds.size());
|
|
||||||
|
|
||||||
Constant **EdgeTable = new Constant*[Succs.size() * Preds.size()];
|
OwningArrayPtr<Constant *> EdgeTable(new Constant*[TableSize]);
|
||||||
Constant *NullValue = Constant::getNullValue(Int64PtrTy);
|
Constant *NullValue = Constant::getNullValue(Int64PtrTy);
|
||||||
for (int i = 0, ie = Succs.size() * Preds.size(); i != ie; ++i)
|
for (size_t i = 0; i != TableSize; ++i)
|
||||||
EdgeTable[i] = NullValue;
|
EdgeTable[i] = NullValue;
|
||||||
|
|
||||||
unsigned Edge = 0;
|
unsigned Edge = 0;
|
||||||
@ -566,7 +566,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(
|
|||||||
Edge += Successors;
|
Edge += Successors;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayRef<Constant*> V(&EdgeTable[0], Succs.size() * Preds.size());
|
ArrayRef<Constant*> V(&EdgeTable[0], TableSize);
|
||||||
GlobalVariable *EdgeTableGV =
|
GlobalVariable *EdgeTableGV =
|
||||||
new GlobalVariable(
|
new GlobalVariable(
|
||||||
*M, EdgeTableTy, true, GlobalValue::InternalLinkage,
|
*M, EdgeTableTy, true, GlobalValue::InternalLinkage,
|
||||||
|
Reference in New Issue
Block a user