<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 14, 2016 at 1:59 AM, Francois Pichet <span dir="ltr"><<a href="mailto:pichet2000@gmail.com" target="_blank">pichet2000@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>No, R5 is not clobbered or having a conflicting DBG_VALUE</div><div><br></div>That sounds more like a missing feature in LiveDebugValue: There is no <span style="font-size:12.8px">DBG_VALUE</span> for R5 in BB#3.<div>LiveDebugValue will only join when all predecessors have the same <span style="font-size:12.8px">DBG_VALUE.</span></div></div></blockquote><div><br></div><div>True. And currently, LiveDebugValues cannot propagate <R5, argc> to BB1 as join fails with one of the predecessor - BB3.</div><div><br></div><div>Here is my thought about handling similar cases:</div><div>I would regard BB1 to be special because join fails to propagate the debug value which is dependent on itself through a cycle. Such blocks need to be identified and handled slightly differently. I think one way to identify them is by using dominator info - look for blocks that dominate its predecessors and propagate debug values from other predecessors unconditionally (also note down the propagated values). This is to be done early during OutLocs initialization. Further, transfer-join would happen normally.</div><div><br></div><div>If join() fails for these special blocks, the propagated debug values need to be reverted (followed by another round of convergence for its successors) and surely this will need extra book-keeping.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div><span style="font-size:12.8px"><br></span></div><div><br></div><div> </div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 12, 2016 at 5:04 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div><blockquote type="cite"><div>On May 12, 2016, at 11:00 AM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank">pichet2000@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Here is a specific case that make the debugging experiences degraded on my target:<div><div>This is a loop simplified CFG:</div></div><div><br></div><div><div>BB#0:</div><div><span style="white-space:pre-wrap">   </span>%R5<def> = OR_rr %R0, %R49    // this is %R5 only def.</div><div><span style="white-space:pre-wrap">   </span>DBG_VALUE %R5, %noreg, !"argc", <!18>; line no:4</div><div>   Successors according to CFG: BB#1<br></div><div><br></div><div>BB#1:</div><div>    Live Ins: %R5</div><div>    Predecessors according to CFG: BB#0 BB#3</div><div>    ...</div><div>    Successors according to CFG: BB#2 BB#4</div><div><br></div><div>BB#2:</div><div>    Live Ins: %R5</div><div>    Predecessors according to CFG: BB#1</div><div><span style="white-space:pre-wrap">    </span>...</div><div>    Successors according to CFG: BB#3</div><div><br></div><div>BB#3:</div><div>    Live Ins: %R5</div><div>    Predecessors according to CFG: BB#2</div><div><span style="white-space:pre-wrap">    </span>...</div><div>    Successors according to CFG: BB#1</div><div><br></div><div>BB#4:</div><div>    Predecessors according to CFG: BB#1</div><div><br></div></div><div><br></div><div>Its obvious to me that the DEBUG_VALUE %R5, %noreg, !"argc" should be propagated to BB#1, BB#2 and BB#3. <br></div><div> </div><div>LiveDebugValue will currently not handle this case. The propagation will not be done for BB#1 because one of its predecessor BB3# doesn't have a DEBUG_VALUE %R5. But R5 is still guaranteed to correspond to argc. <br></div><div><br></div><div>I am investigating how to extend LiveDebugValue for a case like this.</div></div></div></blockquote><div><br></div></div></div><div>That sounds like a bug in LiveDebugValues, or there must be something missing from your example. LiveDebugValues should propagate the DBG_VALUE in this case. Are you sure that R5 isn’t clobbered or regmask’ed by any instruction, and that there is no conflicting DBG_VALUE?</div><div><div><div><br></div><div>-- adrian</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 11, 2016 at 5:53 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">The most obvious place where it is lacking at the moment is that it only supports DBG_VALUEs in registers. Adding support for constant values, memory locations, and fp constants would be a big win!<div><br></div><div>thanks,</div><div>Adrian</div><div><div><div><br><div><blockquote type="cite"><div>On May 11, 2016, at 2:52 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank">pichet2000@gmail.com</a>> wrote:</div><br><div><div dir="ltr">In retrospect I totally agree with you. I am looking at LiveDebugValue again to see if I can improve certain specific cases.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 11, 2016 at 5:14 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On May 11, 2016, at 2:09 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank">pichet2000@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Good point.</div><div><br></div>Currently yes a DEBUG_VALUE "x", vreg0 will be added in BB2. Now I realize this might be wrong in some (corner?) cases where vreg0 no longer refer to "x"<div><br></div><div>My fix would be to propagate the DEBUG_VALUE only if "x" is associated with only a single virtual register.</div><div>BTW, my goal is to generally improve DEBUG_VALUE for optimized code, not make it 100% correct.</div></div></div></blockquote><div><br></div></span>I hold the (perhaps somewhat extreme) position that having debug info the *may* be correct is worse than having no debug info at all, because it means that — in the end — you then cannot trust *anything* reported by the debugger. (There are some debatable corner cases, for example, in contrast to the debugger, the user may know over which path the control flow arrived at the current break point, but these are far in between.)</div><div><br></div><div>That said, I’m very open to improvements to the quality and correctness, so please don’t feel discouraged :-)</div><span><font color="#888888"><div><br></div></font></span><div><span><font color="#888888">-- adrian</font></span><span><br><br><blockquote type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 11, 2016 at 4:43 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On May 11, 2016, at 1:12 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank">pichet2000@gmail.com</a>> wrote:<br>
><br>
</span><span>> Hello,<br>
><br>
> Regarding the problem of debug range for optimized code.<br>
> Currently a DEBUG_VALUE will be inserted after the <def>vregX<br>
> DEBUG_VALUE are only valid until the end of the current MachineBasicBlock. That's the main problem.<br>
> Why not simply iterate over all uses of vregX and insert an DEBUG_VALUE in all the MachineBasicBlocks where vregX is used. (pre regalloc)<br>
><br>
> I prototyped a small pass to do that and at first it seems to improve .debug_loc range validity and enhance the debugging experience for optimized code.<br>
<br>
</span>The problem that I see with this approach is that DEBUG_VALUEs are only valid until the next DEBUG_VALUE that describes the same variable. How does your pass handle:<br>
<br>
  BB0:<br>
    DEBUG_VALUE “x”, vreg0<br>
<br>
  | |<br>
  | BB1:<br>
  |  DEBUG_VALUE “x”, vreg1<br>
  | |<br>
  \_____BB2:<br>
    |    |<br>
    |____/<br>
  BB2:<br>
    vreg0 // still not clobbered here.<br>
<br>
Does it insert a DEBUG_VALUE “x”, vreg0 into BB2?<br>
<span><font color="#888888"><br>
-- adrian<br>
<br>
</font></span></blockquote></div><br></div>
</div></blockquote></span></div><br></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br></div><div>Good time...</div><div>Vikram TV</div><div>CompilerTree Technologies</div><div>Mysore, Karnataka, INDIA</div></div></div></div></div>
</div></div>