<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><br></div></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 class=""><br>
> On May 11, 2016, at 1:12 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com">pichet2000@gmail.com</a>> wrote:<br>
><br>
</span><span class="">> 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 class="HOEnZb"><font color="#888888"><br>
-- adrian<br>
<br>
</font></span></blockquote></div><br></div>