<div dir="ltr">Re-opening this discussion, to get some feedback.<div><br></div><div>Adding alias info is under review in <a href="https://reviews.llvm.org/D38862">https://reviews.llvm.org/D38862</a>.</div><div><br></div><div>An issue that came up, that was bugging me before is how to reason of what is top/bottom of the lattice, and what is the default to test against.</div><div>So talking offline is Sanjoy, we reached a slightly different conclusion which makes more sense to me.</div><div><br></div><div>Current patch has:</div><div><div class="gmail_quote" style="font-size:12.8px">enum ModRefInfo {<br> MRI_NoModRef = 0,<br> MRI_Ref = 1,<br> MRI_Mod = 2,<br> MRI_ModRef = MRI_Ref | MRI_Mod,<br> MRI_Must = 4,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustRef = MRI_Ref | MRI_Must,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustMod = MRI_Mod | MRI_Must,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustModRef = MRI_ModRef | MRI_Must<br>};</div></div><div class="gmail_quote" style="font-size:12.8px"><br></div><div class="gmail_quote" style="font-size:12.8px">Proposed change:</div><div class="gmail_quote" style="font-size:12.8px"><div class="gmail_quote" style="font-size:12.8px">enum ModRefInfo {</div><div class="gmail_quote" style="font-size:12.8px"><div class="gmail_quote" style="font-size:12.8px"> MRI_Must = 0,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustRef = 1,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustMod = 2,</div><div class="gmail_quote" style="font-size:12.8px"> MRI_MustModRef = <span style="font-size:12.8px">MRI_MustRef | MRI_MustMod</span></div> MRI_NoModRef = 4,<br> MRI_Ref = <span style="font-size:12.8px">MRI_NoModRef | </span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">MRI_MustRef</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">, /* Same semantics as right now, i.e. MayRef */</span></div><div class="gmail_quote" style="font-size:12.8px"> MRI_Mod = <span style="font-size:12.8px"> </span><span style="font-size:12.8px">MRI_NoModRef | </span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">MRI_MustMod</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">, /* </span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">Same semantics as right now, i.e.</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">MayMod */</span></div><div class="gmail_quote" style="font-size:12.8px"> MRI_ModRef = MRI_Ref | MRI_Mod, /* <span style="font-size:12.8px">Same semantics as right now, i.e.</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">May Ref or Mod */</span><br></div><div class="gmail_quote" style="font-size:12.8px">};</div><div class="gmail_quote" style="font-size:12.8px"><br></div><div class="gmail_quote" style="font-size:12.8px">With this change:</div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">- the same approach of "set a bit to 0 when additional info is available" will apply to the Must bit, as it does to Ref and Mod.</span><br></div><div class="gmail_quote" style="font-size:12.8px">- we could keep the same checks with <span style="font-size:12.8px">MRI_NoModRef</span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">- MRI_ModRef remains the most conservative answer (top).</span></div><div class="gmail_quote" style="font-size:12.8px">- finding MRI_Must gives more info than MRI_NoModRef, so it makes sense to be bottom.</div><div class="gmail_quote" style="font-size:12.8px">- <span style="font-size:12.8px">MRI_NoModRef</span><span style="font-size:12.8px"> means "no mod or ref, and no must alias".</span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">The only obvious change I see right now will be to to add " | </span><span style="font-size:12.8px">MRI_NoModRef", essentially setting the default to "not must alias".</span></div><div class="gmail_quote" style="font-size:12.8px"><span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Emoji","Segoe UI Symbol",Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px">For GlobalsModRef, we can also always set </span><span style="font-size:12.8px">MRI_NoModRef</span><span style="font-size:12.8px"> bit.</span><br></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">I may be missing details here, happy to elaborate.</span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">Happy Thanksgiving!</span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div class="gmail_quote" style="font-size:12.8px"><span style="font-size:12.8px">Alina</span></div><div class="gmail_quote" style="font-size:12.8px"><br></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 10, 2017 at 1:13 PM, Alina Sbirlea <span dir="ltr"><<a href="mailto:alina.sbirlea@gmail.com" target="_blank">alina.sbirlea@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Oct 10, 2017 at 1:05 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="m_-5619189094996677201h5">
<p><br>
</p>
<div class="m_-5619189094996677201m_-6267006566340524503moz-cite-prefix">On 10/10/2017 02:49 PM, Alina Sbirlea
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>Sigh</div>
<div>I should have taken the time to give a better
example.</div>
<div>The must-alias part is irrelevant to an example
(it only requires read-onlyness)</div>
<div><br>
</div>
<div>You said "LICM doesn't move calls, so we'd
never really care about must-alias for promotion".
I was just pointing out other things move calls
any may want to know.</div>
<div> </div>
<div>If you want an example where the must-alias
part would matter:</div>
<div><br>
</div>
<div>*a = something</div>
<div>foo(a)</div>
<div>b = *a<br>
</div>
<div><br>
</div>
<div>If foo mustalias a (and only a) not only can
you move foo with a, you can actually clone foo
here, change it to be pass-by-value, and promote
the argument inside of it (if you wanted to).</div>
<div><br>
</div>
<div>So you can use this info to, for example, do
interprocedural promotion.</div>
<span class="m_-5619189094996677201m_-6267006566340524503gmail-">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div><br>
</div>
<div>Are we instead looking to set a MRI_Must
bit, disjunct of MRI_Mod, and test for
MRI_Ref&MRI_Must or
MRI_Mod&MRI_Must?</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div>Yes.</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>I didn't mean to pick on the example, sorry if that's
how it came through.</div>
<div><br>
</div>
<div>Since the consensus is to expose the Must info in
ModRefInfo, I'm trying to figure out how to add it in a
way that makes sense to me.</div>
<div>The way I see ModRefInfo is designed right now is to
lower the lattice to NoModRef as fast as possible (start
with ModRef as top, get to NoModRef as bottom). The
implementation is based on having either Mod or Ref and
masking out everything else. <br>
</div>
<div>Introducing a Must bit, means setting it occasionally
(since May is conservative) and then preserving it, so the
opposite: start lattice at bottom, set to top.</div>
<div><br>
</div>
What I was trying, that *somewhat* made sense:<br>
enum ModRefInfo {<br>
MRI_NoModRef = 0,<br>
MRI_Ref = 1,<br>
MRI_Mod = 2,<br>
MRI_ModRef = MRI_Ref | MRI_Mod,<br>
MRI_Must = 4,</div>
<div class="gmail_quote"> MRI_MustRef = MRI_Ref | MRI_Must,</div>
<div class="gmail_quote"> MRI_MustMod = MRI_Mod | MRI_Must,</div>
<div class="gmail_quote"> MRI_MustModRef = MRI_ModRef |
MRI_Must<br>
};</div>
// + shift values in FunctionModRefLocation to 8, 16, 32.</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Recursive masking of MRI_Ref/MRI_Mod
would get replaced by MRI_MustRef/MRI_MustMod.</div>
<div class="gmail_extra">But the top of the lattice is still
MRI_ModRef.</div>
<div class="gmail_extra">While the implementation details *may*
be ok to resolve, there are calls checking for equality to
MRI_Ref or MRI_Mod (not &), so adding the occasional Must
bit seems bad.</div>
</div>
</blockquote>
<br></div></div>
I don't see this as a major problem. Please feel free to fix these
places by replacing the equality checks with mask checks.</div></blockquote><div><br></div></div></div><div>Ok, thank you!</div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="m_-5619189094996677201HOEnZb"><font color="#888888"><br>
<br>
-Hal</font></span><span><br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">So I guess my question is, what's the
right approach here? I feel like I'm not on the right path.</div>
<div class="gmail_extra">
<div class="gmail_quote"><br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span class="m_-5619189094996677201m_-6267006566340524503gmail-">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">In getModRefInfo(CS, Loc), the
MRI_Must bit would then be set if
doesAccessArgPointees and ArgAlias ==
MustAlias for all Args, which seems correct.</div>
</blockquote>
<div><br>
</div>
<div><br>
</div>
</span>
<div>alias == MustAlias for Loc, not for all args.</div>
<div>(IE It it returns a singular result about Loc,
not a result about all args)</div>
<div><br>
</div>
<div>To get the set answer for all args, we'd have
to query further.</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Yes, that's what I meant. In getModRefInfo(CS, Loc)
there is a loop over all args, it checks alias() for each
one.</div>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</span><span><pre class="m_-5619189094996677201m_-6267006566340524503moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</span></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>