[llvm-dev] IR liveness analysis in 2019

Jeremy Morse via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 8 06:50:04 PST 2019


Hi,

I may have a use-case for IR liveness analysis, although it's in the
context of debuginfo. Using the sample code from this bug report [0],
which is a fairly trivial loop:

    int foo(int count) {
      int result = 0;
      for (unsigned long long ix = start; ix != count; ++ix)
        result += external(ix);
      return result;
    }

On x86_64 the 32-bit "count" comparison to 64 bit "ix" necessitates
sign extension of "count". That sign extension gets hoisted out of the
loop, the original value of "count" goes out of liveness, and the
produced debuginfo has no variable location for "count" across the
loop body. I can generate similar examples involving the movement of
pointer bitcasts that lead to pointer variables getting lost.

We can easily generate variable location expressions to recover the
value of "count" from the sign-extended value, so that "count" has a
location across the loop, but (I believe) we'd need a liveness
analysis to determine where & when in the IR to generate such
locations. (Debuginfo of course has to "cope" with things going out of
liveness, whereas liveness has to preserve the functioning of
everything else in IR).

[0] https://bugs.llvm.org/show_bug.cgi?id=38997

--
Thanks,
Jeremy


More information about the llvm-dev mailing list