r222373 - Fix a temporary MDNode leak.

David Blaikie dblaikie at gmail.com
Wed Nov 19 11:05:56 PST 2014


On Wed, Nov 19, 2014 at 10:53 AM, Frederic Riss <friss at apple.com> wrote:

> Author: friss
> Date: Wed Nov 19 12:53:46 2014
> New Revision: 222373
>
> URL: http://llvm.org/viewvc/llvm-project?rev=222373&view=rev
> Log:
> Fix a temporary MDNode leak.
>
> While emitting debug information for function forward decalrations, we
> create DISubprogram objects that aran't stored in the AllSubprograms
> list, and thus won't get finalized by the DIBuilder. During the DIBuilder
> finalize(), the temporary MDNode allocated for the DISubprogram
> Variables field gets RAUWd with a non temporary DIArray. For the forward
> declarations, simply delete that temporary node before we delete the
> parent node, so that it doesn't leak.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=222373&r1=222372&r2=222373&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov 19 12:53:46 2014
> @@ -3398,6 +3398,13 @@ void CGDebugInfo::finalize() {
>        VH = p.second;
>      else
>        VH = it->second;
> +
> +    // Functions have a fake temporary MDNode operand that is supposed
> +    // to get RAUWed upon DIBuilder finalization. Do not leak these
> +    // nodes for the temporary functions we are about to delete.
> +    if (FwdDecl.isSubprogram())
> +
> llvm::MDNode::deleteTemporary(llvm::DISubprogram(FwdDecl).getVariablesNodes());
>

Should we avoid creating a variables node for declarations in the first
place?


> +
>      FwdDecl.replaceAllUsesWith(CGM.getLLVMContext(),
>
> llvm::DIDescriptor(cast<llvm::MDNode>(VH)));
>    }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141119/194940b8/attachment.html>


More information about the cfe-commits mailing list