<div dir="ltr"><div>Hello all,</div><div><br></div><div>Thanks for your replies.</div><div>Indeed, I do not really know how to solve Jeremy's use case. My use case is much simpler, I only want to have a list of variables that are live at an interesting point and insert a new instruction that consumes the live variable at that point.</div><div><br></div><div>So do you think that people do want a liveness analysis at the IR level?</div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Son Tuan Vu</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 8, 2019 at 7:12 PM Quentin Colombet via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks Jeremy for the use case!<br>
<br>
I have a hard time to see how that would work in practice.<br>
<br>
Essentially, in your example, you have to detect that count went out of liveness, so that means we need to somehow maintain the original liveness of the program to do that comparison and that’s where I don’t see how we can do that.<br>
Also, ultimately IIUC we want to mark the extended count value as being count, but it seems to me that this is as hard if not harder to teach the optimization how to propagate this information in the first place instead of analyzing the liveness difference.<br>
<br>
> On Mar 8, 2019, at 6:50 AM, Jeremy Morse via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi,<br>
> <br>
> I may have a use-case for IR liveness analysis, although it's in the<br>
> context of debuginfo. Using the sample code from this bug report [0],<br>
> which is a fairly trivial loop:<br>
> <br>
>    int foo(int count) {<br>
>      int result = 0;<br>
>      for (unsigned long long ix = start; ix != count; ++ix)<br>
>        result += external(ix);<br>
>      return result;<br>
>    }<br>
> <br>
> On x86_64 the 32-bit "count" comparison to 64 bit "ix" necessitates<br>
> sign extension of "count". That sign extension gets hoisted out of the<br>
> loop, the original value of "count" goes out of liveness, and the<br>
> produced debuginfo has no variable location for "count" across the<br>
> loop body. I can generate similar examples involving the movement of<br>
> pointer bitcasts that lead to pointer variables getting lost.<br>
> <br>
> We can easily generate variable location expressions to recover the<br>
> value of "count" from the sign-extended value, so that "count" has a<br>
> location across the loop, but (I believe) we'd need a liveness<br>
> analysis to determine where & when in the IR to generate such<br>
> locations. (Debuginfo of course has to "cope" with things going out of<br>
> liveness, whereas liveness has to preserve the functioning of<br>
> everything else in IR).<br>
> <br>
> [0] <a href="https://bugs.llvm.org/show_bug.cgi?id=38997" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=38997</a><br>
> <br>
> --<br>
> Thanks,<br>
> Jeremy<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>