[llvm-dev] TracksLiveness property and isKill flag

Quentin Colombet via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 28 10:01:57 PDT 2021



> On Apr 27, 2021, at 10:51 PM, Carrot Wei <carrot at google.com> wrote:
> 
> Hi Quentin
> 
> Can I change to comment to
> 
>  // TracksLiveness: True when tracking register liveness accurately.
>  //  While this property is set, register liveness information in basic block
>  //  live-in lists and machine instruction operands (e.g. implicit
>  //  defs) is accurate, kill flags are conservatively accurate (kill flag
>  //  correctly indicates the last use of a register, an operand without kill
>  //  flag may or may not be the last use of a register). This means it can
>  //  be used to change the code in ways that affect the values in
>  // registers, for example by the register scavenger.
>  //  When this property is cleared at a very late time, liveness is no longer
>  //  reliable.

Looks good to me.

> 
> 
> On Tue, Apr 27, 2021 at 1:56 PM Quentin Colombet <qcolombet at apple.com <mailto:qcolombet at apple.com>> wrote:
>> 
>> 
>> 
>>> On Apr 27, 2021, at 1:14 PM, Carrot Wei <carrot at google.com> wrote:
>>> 
>>> Hi Quentin
>>> 
>>> Thanks for the clarification!
>>> A little more questions inlined.
>>> 
>>> On Tue, Apr 27, 2021 at 12:31 PM Quentin Colombet <qcolombet at apple.com> wrote:
>>>> 
>>>> Hi Carrot,
>>>> 
>>>> Kill flags are an optional information and it is not linked to the track liveness property per se.
>>>> 
>>> The following explanation is quite clear to me, but in the
>>> TracksLiveness comment it says kill flag is accurate, it is still very
>>> confusing depends on the meaning of accurate.
>> 
>> Maybe we could patch up the comment, indeed. The reality of this is that the kill flags are accurate but only on the operands where they are set.
>> The rationale here is keeping them up to date can be challenging so most optimizations just clear them when they are unsure. So the only guarantee we make is that they are conservatively correct.
>> 
>>> I'm not a native English
>>> speaker and don't have confidence to make it better, so could you help
>>> to make the comment more clearer? Or you can just paste the new
>>> comment here, I'm happy to make a patch for it.
>>> 
>>>> Essentially, when looking at individual operands, if a kill flag is present it must be correct. If there is no kill flag, the operand can be a last use or not. Also, if you see at least one kill flag within the function, that doesn’t mean all the kill flags are set.
>>>> Bottom line the kill flags are optional, conservatively correct flags.
>>>> 
>>>> If you want reliable last use information, I encourage you to use the LiveIntervals analysis or after regalloc, you can use llvm::recomputeLivenessFlags.
>>>> 
>>> Can LiveVariables provide precise kill flags?
>> 
>> Well, yes, but I wouldn’t recommend to rely on it.
>> 
>> LiveVariables only works on pure SSA form, i.e., before we run the PHI elimination and the two address passes. So if you want precise kill flags after any of these passes, you cannot re-run it.
>> Also keep in mind, that kill flags can be dropped by any optimization passes between LiveVariables and where you may want to use it.
>> Finally, we stopped half way through, but eventually we want to remove that pass. (See the comments in TargetPassConfig.cpp around LiveVariables.)
>> 
>> Putting all together, it is better if your pass doesn’t depend on kill flags to do the right thing. Instead use LiveIntervals.
>> 
> So there is no simple and lightweight method to get precise kill flags
> in SSA form.


I am afraid there is not.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210428/c4c22650/attachment.html>


More information about the llvm-dev mailing list