[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-dev
Subject:    Re: [llvm-dev] TracksLiveness property and isKill flag
From:       Quentin Colombet via llvm-dev <llvm-dev () lists ! llvm ! org>
Date:       2021-04-28 17:01:57
Message-ID: 961F9AAB-7790-46F2-93D5-8EA20A450CE5 () apple ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On Apr 27, 2021, at 10:51 PM, Carrot Wei <carrot@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@apple.com \
> <mailto:qcolombet@apple.com>> wrote:
> > 
> > 
> > 
> > > On Apr 27, 2021, at 1:14 PM, Carrot Wei <carrot@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@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.


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote \
type="cite" class=""><div class="">On Apr 27, 2021, at 10:51 PM, Carrot Wei &lt;<a \
href="mailto:carrot@google.com" class="">carrot@google.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">Hi Quentin</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">Can I change to comment to</span><br style="caret-color: rgb(0, \
0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" class="">&nbsp;// \
TracksLiveness: True when tracking register liveness accurately.</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" class="">&nbsp;// \
&nbsp;While this property is set, register liveness information in basic \
block</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">&nbsp;// &nbsp;live-in lists and machine instruction operands \
(e.g. implicit</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; \
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">&nbsp;// &nbsp;defs) is accurate, kill flags are conservatively \
accurate (kill flag</span><br style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// &nbsp;correctly indicates \
the last use of a register, an operand without kill</span><br style="caret-color: \
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// &nbsp;flag may or may not \
be the last use of a register). This means it can</span><br style="caret-color: \
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// &nbsp;be used to change \
the code in ways that affect the values in</span><br style="caret-color: rgb(0, 0, \
0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: \
normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// registers, for example by \
the register scavenger.</span><br style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// &nbsp;When this property \
is cleared at a very late time, liveness is no longer</span><br style="caret-color: \
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&nbsp;// &nbsp;reliable.</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""></div></blockquote><div><br class=""></div><div>Looks good to me.</div><br \
class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: \
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" class="">On Tue, Apr \
27, 2021 at 1:56 PM Quentin Colombet &lt;</span><a href="mailto:qcolombet@apple.com" \
style="font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: \
auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; \
widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px;" class="">qcolombet@apple.com</a><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&gt; wrote:</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""><br \
class=""><br class=""><blockquote type="cite" class="">On Apr 27, 2021, at 1:14 PM, \
Carrot Wei &lt;<a href="mailto:carrot@google.com" class="">carrot@google.com</a>&gt; \
wrote:<br class=""><br class="">Hi Quentin<br class=""><br class="">Thanks for the \
clarification!<br class="">A little more questions inlined.<br class=""><br \
class="">On Tue, Apr 27, 2021 at 12:31 PM Quentin Colombet &lt;<a \
href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>&gt; wrote:<br \
class=""><blockquote type="cite" class=""><br class="">Hi Carrot,<br class=""><br \
class="">Kill flags are an optional information and it is not linked to the track \
liveness property per se.<br class=""><br class=""></blockquote>The following \
explanation is quite clear to me, but in the<br class="">TracksLiveness comment it \
says kill flag is accurate, it is still very<br class="">confusing depends on the \
meaning of accurate.<br class=""></blockquote><br class="">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.<br class="">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.<br \
class=""><br class=""><blockquote type="cite" class="">I'm not a native English<br \
class="">speaker and don't have confidence to make it better, so could you help<br \
class="">to make the comment more clearer? Or you can just paste the new<br \
class="">comment here, I'm happy to make a patch for it.<br class=""><br \
class=""><blockquote type="cite" class="">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.<br class="">Bottom line the \
kill flags are optional, conservatively correct flags.<br class=""><br class="">If \
you want reliable last use information, I encourage you to use the LiveIntervals \
analysis or after regalloc, you can use llvm::recomputeLivenessFlags.<br class=""><br \
class=""></blockquote>Can LiveVariables provide precise kill flags?<br \
class=""></blockquote><br class="">Well, yes, but I wouldn't recommend to rely on \
it.<br class=""><br class="">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.<br class="">Also keep in mind, \
that kill flags can be dropped by any optimization passes between LiveVariables and \
where you may want to use it.<br class="">Finally, we stopped half way through, but \


[Attachment #6 (text/plain)]

_______________________________________________
LLVM Developers mailing list
llvm-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic