diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-11-17 13:49:37 +0000 | 
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-11-17 13:49:37 +0000 | 
| commit | 96e1e396420d45fb4a1d3891105390c53120e8f6 (patch) | |
| tree | 6a122df933ba5eb8ede0a4a1e35d8109dfa9beea /llvm/lib/Transforms | |
| parent | dca1ff8909bb630d489dc4c35eb7896e7a272a46 (diff) | |
| download | bcm5719-llvm-96e1e396420d45fb4a1d3891105390c53120e8f6.tar.gz bcm5719-llvm-96e1e396420d45fb4a1d3891105390c53120e8f6.zip | |
Plug a memory leak in the GCOV profiling emitter, which never released the edge table memory.
llvm-svn: 168259
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index e9192e5cdd5..a8adaa62d7b 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -540,13 +540,13 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(    // read it. Threads and invoke make this untrue.    // emit [(succs * preds) x i64*], logically [succ x [pred x i64*]]. +  size_t TableSize = Succs.size() * Preds.size();    Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx); -  ArrayType *EdgeTableTy = ArrayType::get( -      Int64PtrTy, Succs.size() * Preds.size()); +  ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize); -  Constant **EdgeTable = new Constant*[Succs.size() * Preds.size()]; +  OwningArrayPtr<Constant *> EdgeTable(new Constant*[TableSize]);    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;    unsigned Edge = 0; @@ -566,7 +566,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(      Edge += Successors;    } -  ArrayRef<Constant*> V(&EdgeTable[0], Succs.size() * Preds.size()); +  ArrayRef<Constant*> V(&EdgeTable[0], TableSize);    GlobalVariable *EdgeTableGV =        new GlobalVariable(            *M, EdgeTableTy, true, GlobalValue::InternalLinkage, | 

