<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 10, 2017 at 2:19 PM Jonas Devlieghere <<a href="mailto:jdevlieghere@apple.com">jdevlieghere@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br><blockquote type="cite"><div>On Oct 10, 2017, at 8:17 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_6342041995048870073Apple-interchange-newline"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 10, 2017 at 12:06 PM Jonas Devlieghere <<a href="mailto:jdevlieghere@apple.com" target="_blank">jdevlieghere@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br><blockquote type="cite"><div>On Oct 10, 2017, at 6:24 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_6342041995048870073m_-8536887263197915193Apple-interchange-newline"><div><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 10, 2017 at 10:06 AM Jonas Devlieghere via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">JDevlieghere marked 2 inline comments as done.<br>JDevlieghere added inline comments.<br><br><br>================<br>Comment at: lib/DebugInfo/DWARF/DWARFVerifier.cpp:423<br>+    // Make sure specification and abstract origin have compatible tag.<br>+    if (auto Offset = AttrValue.Value.getAsReference()) {<br>+<br>----------------<br>dblaikie wrote:<br>> Can you use DWARFDie::getAttributeValueAsReferencedDie here, perhaps?<br>Unfortunately not, because this makes use of `getUnitForOffset` which in turn uses a list of units that isn't build when doing the verification.<br></blockquote><div><br>Not sure I understand - this code calls getDIEForOffset, which calls getUnitForOffset as well. So why would one path be usable and the other not?<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div>I would have to double check with the code in front of me, but it uses an upper_bound to find the right unit based on the offset, and this code path doesn’t populate that list. I noticed this earlier when I was trying to understand why the name of the subroutine is shown when dumping the debug info but not when running the verifier. I think this is the result of only considering one unit at a time when verifying, but I didn’t dig much deeper once I had found the explanation. </div></div></div></blockquote><div><br>Yeah, I'm really not understanding the difference between these possible codepaths.<br><br>The code in this review calls:<br><br>  auto Offset = AttrValue.Value.getAsReference()<br>  DCtx.getDIEForOffset(*Offset)<br>  ->CUs.getUnitForOffset(*Offset)->getDIEForOffset(*Offset);<br><br>the code in DWARFDie::getAttributeValueAsReferencedDie calls:<br><br>  auto SpecRef = toReference(find(Attr));<br>  U->getUnitSection().getUnitForOffset(*SpecRef)->getDIEForOffset(*SpecRef);<br><br>(where 'getUnitSection' returns DWARFUnitSectionBase, and 'CUs' is a DWARFUnitSectionBase (well, a class derived from it, DWARFUnitSection<DWARFCompileUnit>)<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div>The difference is that DWARFVerifier::handleDebugInfo is using “dummy” objects for the DWARFUnitSection objects:</div><div><br></div><div>DWARFUnitSection<DWARFTypeUnit> TUSection{};</div><div>DWARFUnitSection<DWARFCompileUnit> CUSection{};</div><div><br></div><div>As a result the list with CUs is empty and U->getUnitSection().getUnitForOffset(*Offset) returns nothing while CUs.getUnitForOffset(*Offset) returns the correct unit. </div><div><br></div><div>I want to emphasize that I’m not trying to defend the current approach. Could you have a quick look at DWARFVerifier::handleDebugInfo and help me understand if there’s a good reason for this or maybe it is something that just needs to be fixed. </div></div></div></blockquote><div><br>Adrian - could you take a look here & see why DWARFVerifier::handleDebugInfo is creating empty TUSection/CUSection, rather than passing the DCtx's populated sections in? (that's my rough reading of the code, at least)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div><br></div><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote"><div><br>So I'm really having a hard time understanding why these codepaths would be different & it seems subtle/worth fixing if they are.<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div>Definitely! I’m relatively new to the code base so it’s not always obvious when something is a bug or I just lack the necessary understanding. </div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><br></div><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Furthermore, this is (probably) slightly more efficient as we already have the attribute value and therefore do not need to do any indirections via the abbrev declaration.<br><br><br><a href="https://reviews.llvm.org/D38719" rel="noreferrer" target="_blank">https://reviews.llvm.org/D38719</a></blockquote></div></div></div></blockquote></div></div></blockquote></div></div></div></blockquote></div></div></blockquote></div></div>