diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-10 18:01:58 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-10 18:01:58 +0000 |
| commit | 457bfc779a8d47ac70265923fde4b0072a9c4bcc (patch) | |
| tree | a85f43f22f5361a7f3387945155a27a345f6289c | |
| parent | 7553a4bca08767c2b80a8365f86ff36619815088 (diff) | |
| download | bcm5719-llvm-457bfc779a8d47ac70265923fde4b0072a9c4bcc.tar.gz bcm5719-llvm-457bfc779a8d47ac70265923fde4b0072a9c4bcc.zip | |
DebugInfo: Stop leaking temporaries in DIBuilder::createCompileUnit()
Stop leaking temporary nodes from `DIBuilder::createCompileUnit()`.
`replaceAllUsesWith()` doesn't delete the nodes, so we need to delete
them "manually" (well, `TempMDTuple` does that for us).
Similarly, stop leaking the temporary nodes used for variables of
subprograms.
llvm-svn: 234617
| -rw-r--r-- | llvm/include/llvm/IR/DIBuilder.h | 10 | ||||
| -rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 19 |
2 files changed, 15 insertions, 14 deletions
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 260cd827a04..eb5cdd60427 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -57,11 +57,11 @@ namespace llvm { Module &M; LLVMContext &VMContext; - MDTuple *TempEnumTypes; - MDTuple *TempRetainTypes; - MDTuple *TempSubprograms; - MDTuple *TempGVs; - MDTuple *TempImportedModules; + TempMDTuple TempEnumTypes; + TempMDTuple TempRetainTypes; + TempMDTuple TempSubprograms; + TempMDTuple TempGVs; + TempMDTuple TempImportedModules; Function *DeclareFn; // llvm.dbg.declare Function *ValueFn; // llvm.dbg.value diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 9ba20109168..f3b4997efb7 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -93,11 +93,11 @@ void DIBuilder::finalize() { TempSubprograms->replaceAllUsesWith(SPs.get()); for (unsigned i = 0, e = SPs.size(); i != e; ++i) { DISubprogram SP = cast<MDSubprogram>(SPs[i]); - if (MDNode *Temp = SP.getVariables().get()) { + if (MDTuple *Temp = SP.getVariables().get()) { const auto &PV = PreservedVariables.lookup(SP); SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end()); DIArray AV = getOrCreateArray(Variables); - Temp->replaceAllUsesWith(AV.get()); + TempMDTuple(Temp)->replaceAllUsesWith(AV.get()); } } @@ -143,18 +143,19 @@ DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename, // TODO: Once we make MDCompileUnit distinct, stop using temporaries here // (just start with operands assigned to nullptr). - TempEnumTypes = MDTuple::getTemporary(VMContext, None).release(); - TempRetainTypes = MDTuple::getTemporary(VMContext, None).release(); - TempSubprograms = MDTuple::getTemporary(VMContext, None).release(); - TempGVs = MDTuple::getTemporary(VMContext, None).release(); - TempImportedModules = MDTuple::getTemporary(VMContext, None).release(); + TempEnumTypes = MDTuple::getTemporary(VMContext, None); + TempRetainTypes = MDTuple::getTemporary(VMContext, None); + TempSubprograms = MDTuple::getTemporary(VMContext, None); + TempGVs = MDTuple::getTemporary(VMContext, None); + TempImportedModules = MDTuple::getTemporary(VMContext, None); // TODO: Switch to getDistinct(). We never want to merge compile units based // on contents. MDCompileUnit *CUNode = MDCompileUnit::get( VMContext, Lang, MDFile::get(VMContext, Filename, Directory), Producer, - isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes, - TempRetainTypes, TempSubprograms, TempGVs, TempImportedModules); + isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(), + TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(), + TempImportedModules.get()); // Create a named metadata so that it is easier to find cu in a module. // Note that we only generate this when the caller wants to actually |

