<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 19, 2014 at 10:53 AM, Frederic Riss <span dir="ltr"><<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: friss<br>
Date: Wed Nov 19 12:53:46 2014<br>
New Revision: 222373<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222373&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222373&view=rev</a><br>
Log:<br>
Fix a temporary MDNode leak.<br>
<br>
While emitting debug information for function forward decalrations, we<br>
create DISubprogram objects that aran't stored in the AllSubprograms<br>
list, and thus won't get finalized by the DIBuilder. During the DIBuilder<br>
finalize(), the temporary MDNode allocated for the DISubprogram<br>
Variables field gets RAUWd with a non temporary DIArray. For the forward<br>
declarations, simply delete that temporary node before we delete the<br>
parent node, so that it doesn't leak.<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=222373&r1=222372&r2=222373&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=222373&r1=222372&r2=222373&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov 19 12:53:46 2014<br>
@@ -3398,6 +3398,13 @@ void CGDebugInfo::finalize() {<br>
       VH = p.second;<br>
     else<br>
       VH = it->second;<br>
+<br>
+    // Functions have a fake temporary MDNode operand that is supposed<br>
+    // to get RAUWed upon DIBuilder finalization. Do not leak these<br>
+    // nodes for the temporary functions we are about to delete.<br>
+    if (FwdDecl.isSubprogram())<br>
+      llvm::MDNode::deleteTemporary(llvm::DISubprogram(FwdDecl).getVariablesNodes());<br></blockquote><div><br>Should we avoid creating a variables node for declarations in the first place?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
     FwdDecl.replaceAllUsesWith(CGM.getLLVMContext(),<br>
                                llvm::DIDescriptor(cast<llvm::MDNode>(VH)));<br>
   }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>