<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 29, 2010, at 9:51 AM, Benjamin Kramer wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Verdana; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><br>On 28.06.2010, at 20:25, Devang Patel wrote:<br><br><blockquote type="cite">Author: dpatel<br></blockquote><blockquote type="cite">Date: Mon Jun 28 13:25:03 2010<br></blockquote><blockquote type="cite">New Revision: 107027<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=107027&view=rev">http://llvm.org/viewvc/llvm-project?rev=107027&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">Preserve deleted function's local variables' debug info.<br></blockquote><blockquote type="cite">Radar 8122864.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Added:<br></blockquote><blockquote type="cite">  llvm/trunk/test/FrontendC/2010-06-28-DbgLocalVar.c<br></blockquote><blockquote type="cite">Modified:<br></blockquote><blockquote type="cite">  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br></blockquote><blockquote type="cite">  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br></blockquote><blockquote type="cite">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=107027&r1=107026&r2=107027&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=107027&r1=107026&r2=107027&view=diff</a><br></blockquote><blockquote type="cite">==============================================================================<br></blockquote><blockquote type="cite">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br></blockquote><blockquote type="cite">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jun 28 13:25:03 2010<br></blockquote><blockquote type="cite">@@ -1386,6 +1386,7 @@<br></blockquote><blockquote type="cite">/// If there are global variables in this scope then create and insert<br></blockquote><blockquote type="cite">/// DIEs for these variables.<br></blockquote><blockquote type="cite">DIE *DwarfDebug::updateSubprogramScopeDIE(const MDNode *SPNode) {<br></blockquote><blockquote type="cite">+  ProcessedSPNodes.insert(SPNode);<br></blockquote><blockquote type="cite"> CompileUnit *SPCU = getCompileUnit(SPNode);<br></blockquote><blockquote type="cite"> DIE *SPDie = SPCU->getDIE(SPNode);<br></blockquote><blockquote type="cite"> assert(SPDie && "Unable to find subprogram DIE!");<br></blockquote><blockquote type="cite">@@ -2005,6 +2006,40 @@<br></blockquote><blockquote type="cite">///<br></blockquote><blockquote type="cite">void DwarfDebug::endModule() {<br></blockquote><blockquote type="cite"> if (!FirstCU) return;<br></blockquote><blockquote type="cite">+  const Module *M = MMI->getModule();<br></blockquote><blockquote type="cite">+  if (NamedMDNode *AllSPs = M->getNamedMetadata("llvm.dbg.sp")) {<br></blockquote><blockquote type="cite">+    for (unsigned SI = 0, SE = AllSPs->getNumOperands(); SI != SE; ++SI) {<br></blockquote><blockquote type="cite">+      if (ProcessedSPNodes.count(AllSPs->getOperand(SI)) != 0) continue;<br></blockquote><blockquote type="cite">+      DISubprogram SP(AllSPs->getOperand(SI));<br></blockquote><blockquote type="cite">+      if (!SP.Verify()) continue;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+      // Collect info for variables that were optimized out.<br></blockquote><blockquote type="cite">+      StringRef FName = SP.getLinkageName();<br></blockquote><blockquote type="cite">+      if (FName.empty())<br></blockquote><blockquote type="cite">+        FName = SP.getName();<br></blockquote><blockquote type="cite">+      NamedMDNode *NMD =<span class="Apple-converted-space"> </span><br></blockquote><blockquote type="cite">+        M->getNamedMetadata(Twine("llvm.dbg.lv.", getRealLinkageName(FName)));<br></blockquote><blockquote type="cite">+      if (!NMD) continue;<br></blockquote><blockquote type="cite">+      unsigned E = NMD->getNumOperands();<br></blockquote><blockquote type="cite">+      if (!E) continue;<br></blockquote><blockquote type="cite">+      DbgScope *Scope = new DbgScope(NULL, DIDescriptor(SP), NULL);<br></blockquote><br>Hi Devang,<br><br>valgrind says those DbgScopes are leaked:<br></span></blockquote></div><br><div>Indeed. Fixed.</div><div>-</div><div>Devang</div></body></html>