[llvm-dev] IsDead, IsKill

Quentin Colombet via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 11 11:27:26 PDT 2019



> On Mar 11, 2019, at 10:34 AM, LLVM Mailing List <carl-llvm-dev at petosoft.com> wrote:
> 
> Thanks.
> 
> I saw the header comments but it wasn’t clear to me what the difference between those concepts is?
> 
> My slightly vague understanding is IsDef means that the register specified by this operand is set by the machine instruction.  

Correct!

> So I understand that to mean the MO will override that register?

Override in the case of a redefinition, but define otherwise.
The backends are in SSA form until register allocation (we destroy SSA during the PHIElmination pass, more precisely), so the semantic is more that the virtual register is defined since there is no redefinition in SSA.

> 
> Also things like early clobber, perhaps there is another document that clarifies some of these concepts?

Not that I know off, but I found the comment clear enough x).

So early clobber is a mean to extend the live range of a definition before the uses of the same instruction.
For instance, let say that your HW requires that the register defined by an instruction does not overlap with any of the input register, e.g., `r0 = inst r0, r1` is invalid because r0 is both a use and and def of inst, the way to tell that to the compiler is by marking the definition as early clobber.
This will effectively create an interference between the registers used by inst and its definition, such that the register allocator will not be allowed to use the same register for the definition and the rest of its operands.

> 
> 
> 
> In an example .td file that I’m looking at, how would I tell the compiler “this will use register XX but will damage its contents so it’s value is no longer available to later instructions”?

On top of my head, I am not sure we can precisely model exactly that.
The closest thing I can think of is using tied operand. Basically, you tie you use to a definition so it gets destroyed by this use:
op0, op1(tie:2) = inst op2, …

Here op0 would be your true definition of inst, and op1 is the “override” of op2 (op1 is tied to operand number 2).
Then you can add isDead to op1 and you have almost what you want.

This modeling is not exactly what you want, because op1 will prevent op0 to reuse the register of op2. Therefore, essentially, you artificially increase the register pressure by one locally.

For the context, the tie operands are usually used for 2-address operation, thus we don’t have this problem of a fake definition increasing the register pressure.

> 
> 
> 
>> On 11 Mar 2019, at 16:43, Quentin Colombet <qcolombet at apple.com> wrote:
>> 
>> Hi Carl,
>> 
>> Look at the comments in include/llvm/CodeGen/MachineOperand.h for the documentation of the various flags.
>> 
>> IsDead means that a definition is never used.
>> IsKill means that this is the last use of a given register.
>> 
>> Cheers,
>> -Quentin
>> 
>>> On Mar 11, 2019, at 8:54 AM, LLVM Mailing List via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>> 
>>> Is there anything that documents what these properties (and the other similar properties) do on the MachineOperand class?
>>> 
>>> I’m trying to debug an instruction selection issue I think.  It’s hard to find documentation on what the MO properties mean.
>>> 
>>> Thanks,
>>> Carl
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>> 
> 



More information about the llvm-dev mailing list