<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 27, 2015 at 11:32 AM, Aboud, Amjad <span dir="ltr"><<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I am not sure what is imported entry is, and if it could be located inside a lexical block.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">When you create an imported entry you call the “getOrCreateContextDIE”, this function will check for, Compile-Unit, File, Namespace, Type, Subprogram context.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">If none match, it calls “getDIE” function:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">DIE *DwarfUnit::getDIE(<span style="color:blue">const</span> DINode *D)
<span style="color:blue">const</span> {<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">
<span style="color:blue">if</span> (isShareableAcrossCUs(D))<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">
<span style="color:blue">return</span> DU->getDIE(D);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">
<span style="color:blue">return</span> MDNodeToDieMap.lookup(D);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">}<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Maybe imported entries fit with the first condition check of “</span><span style="font-size:9.5pt;font-family:Consolas">isShareableAcrossCUs</span><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">”,
but the function static variables will have a lexical block context and when we will look for this context in the “</span><span style="font-size:9.5pt;font-family:Consolas">MDNodeToDieMap</span><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">”
map it will not be there, because we do not map lexical block MDNode to lexical block DIE.</span></p></div></div></blockquote><div><br>Take a look in DwarfCompileUnit::cosntructScopeDIE, around half way through, you'll find this code:<br><br><div> unsigned ChildScopeCount;</div><div><br></div><div> // We create children here when we know the scope DIE is not going to be</div><div> // null and the children will be added to the scope DIE.</div><div> createScopeChildrenDIE(Scope, Children, &ChildScopeCount);</div><div><br></div><div> // Skip imported directives in gmlt-like data.</div><div> if (!includeMinimalInlineScopes()) {</div><div> // There is no need to emit empty lexical block DIE.</div><div> for (const auto &E : DD->findImportedEntitiesForScope(DS))</div><div> Children.push_back(</div><div> constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));</div><div> }</div><div><br><<It seems to me like the code there that the logic for static variables should go here too - the same way imported entities are dealt with. Then, if we have any static variables, imported entities, we create this scope - otherwise we put it in the parent>> <br><br></div><div> // If there are only other scopes as children, put them directly in the</div><div> // parent instead, as this scope would serve no purpose.</div><div> if (Children.size() == ChildScopeCount) {</div><div> FinalChildren.insert(FinalChildren.end(),</div><div> std::make_move_iterator(Children.begin()),</div><div> std::make_move_iterator(Children.end()));</div><div> return;</div><div> }</div><div> ScopeDIE = constructLexicalScopeDIE(Scope);</div><div> assert(ScopeDIE && "Scope DIE should not be null.");<br><br><br></div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Also, right now, we decide if to create the lexical block DIE or not depends on the local variable children only, as the function static variables DIE and the
type DIEs were not attached yet to the lexical block DIE.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">This, is why I also suggest to create all lexical blocks at first and once all its children are created, we can revisit this lexical block FIE and decide if
it worth collapsing with parent.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Amjad<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, May 27, 2015 21:14<br>
<b>To:</b> <a href="mailto:reviews%2BD9960%2Bpublic%2B41c324f590718ccc@reviews.llvm.org" target="_blank">reviews+D9960+public+41c324f590718ccc@reviews.llvm.org</a><br>
<b>Cc:</b> Aboud, Amjad; Eric Christopher; Benjamin Kramer; <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>; Robinson, Paul<span class=""><br>
<b>Subject:</b> Re: [PATCH] Refactor debug info lexical block generation<u></u><u></u></span></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Perhaps it'd be good to have a general design discussion here, rather than in the form of line-by-line code review. A few broad issues have been brought up by both Paul and Frederic that sound reasonable to me, though I've not looked at
the code in detail yet.</p><div><div class="h5"><br>
<br>
Is there any reason this wouldn't be implemented the same way as the imported entity work? Where we check for imported entities at scope construction time to decide whether to create that scope or not.<u></u><u></u></div></div><p></p>
</div><div><div class="h5">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Sun, May 24, 2015 at 9:00 AM, Amjad Aboud <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Hi echristo, bkramer, dblaikie,<br>
<br>
This patch is needed for resolving Bug 19238.<br>
It is the first part which will be followed by D9758.<br>
<br>
The idea is to create all debug info lexical block DIEs and add them to the DIScope->DIE map.<br>
Latter, just before emitting the DIEs, we will search the DIE tree and collapse all redundant (useless) DIE lexical blocks.<br>
<br>
REPOSITORY<br>
rL LLVM<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D9960&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OPf7e3fKeL-BZequzjvcub1WjCow-t_MoGWle2VS-jY&s=KgsP507mXB656ZMxpwJXkV6z0S-84QJZ8iofVL11zPc&e=" target="_blank">http://reviews.llvm.org/D9960</a><br>
<br>
Files:<br>
include/llvm/CodeGen/DIE.h<br>
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
test/DebugInfo/useless_lexical_scope.ll<br>
<br>
EMAIL PREFERENCES<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OPf7e3fKeL-BZequzjvcub1WjCow-t_MoGWle2VS-jY&s=ZBGcwMLAhG2Ogfjsp5dDyvdMam1lTShMHtgIGl6M3XY&e=" target="_blank">
http://reviews.llvm.org/settings/panel/emailpreferences/</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p><span class="">
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></span></div>
</blockquote></div><br></div></div>