[PATCH] D70497: [DBG] Teach DebugEntityHistoryCalculator about Kill instructions.

Tom Weaver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 07:48:17 PST 2019


TWeaver added a comment.

Apologies for the lack lustre description and vagueness of all this. Also, this is late coming due to sickness. My deepest and humblest apologies. Hope this clear things up though! enjoy.

Why it's safe to ignore KILL instructions when generating live debug location list ranges.

Essentially KILL instructions are NOOPs. They do not change the bit fields of any of the registers they touch. They merely adjust the liveness of a register or subregister to indicate to future consumers that the liveness of some value in a register has changed.

This is mostly useful for handling cases where, before KILL instructions are inserted, an assignment from a super register to a subregister takes place. A cases where some 64-bit maths takes place to compute a value that is then returned in a 32-bit register (for some arbitrary case) could be as follows:

0  // psuedo for ease of reading.
1  RAX = Do 64-bit computation and store value
2  assign value in RAX to EAX
3  return EAX

step 2 of the above example could, in some cases, be a NOOP and a completely unnecessary step as the computed value already exists in EAX. There is a semantic meaning to assignment from RAX to EAX that we want to preserve, but, we don't want to perform a reassignment into a register that already holds the same value. As a result, this assignment is replaced with a KILL instruction that describes the assignment from RAX to EAX. The above example would look something like this:

0  // psuedo for ease of reading.
1  RAX = Do 64-bit computation and store value
2  EAX = KILL killed RAX, RAX
3  return EAX

This now indicates that the value we originally held in RAX is no longer available past the point of the KILL but without explicitly performing the assignment/move/copy from super-register to sub-register.

This is great for generating live information about values in registers for passes and optmisations that care about the liveness of said values. But in the case of Debugging Information, we want to preserve the liveness of some value for as long as possible. Therefore, it doesn't matter if the live range of some value in a super register is no longer useable for some computation, what matters is that the value of the register remains unchanged and is still safe to read in a debugger.

Any changes to the value of said register by some operation will be picked up by the debug entity history calculator which will soundly terminate whenever it's clobbered, however, a KILL instruction does not actually clobber anything (it's merely a liveness indicator/instruction/adjuster/meta-thing).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70497/new/

https://reviews.llvm.org/D70497





More information about the llvm-commits mailing list