<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, May 8, 2017 at 4:19 PM Greg Clayton <<a href="mailto:clayborg@gmail.com">clayborg@gmail.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"><div><blockquote type="cite"><div>On May 8, 2017, at 4:03 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_4788506496020266682Apple-interchange-newline"><div><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, May 3, 2017 at 1:57 PM Greg Clayton <<a href="mailto:clayborg@gmail.com" target="_blank">clayborg@gmail.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"><div><blockquote type="cite"><div>On May 3, 2017, at 1:45 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_4788506496020266682m_-8909822520519760362Apple-interchange-newline"><div><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, May 3, 2017 at 1:32 PM Greg Clayton 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clayborg added a comment.<br>
<br>
In <a href="https://reviews.llvm.org/D32821#745213" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32821#745213</a>, @dblaikie wrote:<br>
<br>
> I haven't followed some of the design direction Adrian's been pointing this work in - so all of this is subject to discussion, etc:<br>
><br>
> 1. I'd expect not to build an entire representation of all ranges up-front, then verify them (uses more memory, etc) - but rather verify during a traversal of the DIEs instead<br>
<br>
<br>
The whole reason we need this is to look for overlapping functions between all CUs. This helps us to identify exactly which DIEs overlap.</blockquote><div><br>If it's true that no DIEs should overlap, and all DIEs should be a subset of their parent - then there's no need to compare two DIEs that aren't siblings* because they can't overlap. The only comparisons that should be needed would be between immediate siblings, and siblings and parents - not all possible pairs of nodes. Right?<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>That is how this is coded. Only top DW_TAG_subprogram DIEs get added to the AllFunctionRangeInfos. So when checking for overlap, we just check between adjacent DW_TAG_subprogram. Since these are in a std::set, they are ordered already. So we just check:</div><div><br></div><div>for I in AllFunctionRangeInfos.size():</div><div>  AllFunctionRangeInfos[I].Contains(AllFunctionRangeInfos[I+1])</div></div></blockquote><div><br>Ah, that makes loads of sense - nice!<br><br>So why aren't the lexical blocks scopes handled the same way?<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>They are now. The new <span style="font-size:11px">NonOverlappingRanges class does this by storing things a std::set. We now check everything on the fly.</span></div></div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote"><div><br>(& indeed, this is what I'm getting at about the duplicate code across this - I'm not understanding why there are two different ways of testing intersects or subset - and two different codepaths for the error messages too)<br><br>What I'm picturing is a single device, much like what I wrote in the patch I provided last week, I think. That device/class represents a scope (in the general sense, not the lexical_scope sense), with an optional parent node + range and a list of children node+ranges. There would be an explicit instance for the file level (with no parent) that is used by every compile_unit's ranges. Another (hopefully local/non-member version, passed down - but it could be a member) created when visiting a top level compile unit - for its subprograms. And any number more created on the stack for the lexical scopes.<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>That is essentially what we have now, we just have a const class and one in/out class.</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote"><div><br>This object would handle error message printing for both sibling overlap and not-contained-in-parent errors, in one place with one message/handling/etc.<br></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>I guess we could switch over to using NonOverlappingRanges in the DieRangeInfo as well. I didn't want to put the error handling inside these classes because they need to access the error count.</div></div></blockquote><div><br>Rolling the error handling in would reduce a bunch of the duplication/complexity, I think.<br><br>Worst case, the functions that could error could return the number of errors they printed, and be used like:<br><br>  ErrorCount += NOR.AddRange(Die);<br> <br>For example.<br><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"><div> This is pretty close to what is there now, I just don't use <span style="font-size:11px">NonOverlappingRanges in the DieRangeInfo currently... I will switch that over and see what simplifies out.</span></div></div><div style="word-wrap:break-word"><div><span style="font-size:11px"><br></span></div><div><span style="font-size:11px">Greg</span></div><div><br></div></div></blockquote></div></div>