<div dir="ltr">Hi Nuno,<div><br></div><div>The definition for setting Must is whether must alias with the location was found and there is no alias with other locations.</div><div>Yes, it's possible a write does not occur for <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">cmpxchg, and that's fine. ModRef means it may read and it may write, but it doesn't necessarily mean it will. MustModRef means it may read and it may write, and if so, there is a must alias with that location and with no other locations. It doesn't mean it must read and write to that location.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The opposite scenario: if, say, you knew for sure statement S writes to A, and may write to B, then Must will not be set, because of B. So you get Mod.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Whereas if S *may* write to A and accesses nothing else, then you get MustMod.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div>Does this make sense?<br></div><div><br></div><div>Please let me know if I'm missing something obvious here or whether I should update the documentation to make this clearer.</div><div><br></div><div>Thanks,</div><div>Alina</div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 22, 2017 at 8:10 AM, Nuno Lopes <span dir="ltr"><<a href="mailto:nunoplopes@sapo.pt" target="_blank">nunoplopes@sapo.pt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alina,<br>
<br>
Some comments below; I think some operations cannot be marked as MustModRef:<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@@ -440,9 +479,17 @@ ModRefInfo AAResults::getModRefInfo(cons<br>
   if (isStrongerThanMonotonic(CX->g<wbr>etSuccessOrdering()))<br>
     return ModRefInfo::ModRef;<br>
<br>
-  // If the cmpxchg address does not alias the location, it does not access it.<br>
-  if (Loc.Ptr && !alias(MemoryLocation::get(CX)<wbr>, Loc))<br>
-    return ModRefInfo::NoModRef;<br>
+  if (Loc.Ptr) {<br>
+    AliasResult AR = alias(MemoryLocation::get(CX), Loc);<br>
+    // If the cmpxchg address does not alias the location, it does not access<br>
+    // it.<br>
+    if (AR == NoAlias)<br>
+      return ModRefInfo::NoModRef;<br>
+<br>
+    // If the cmpxchg address aliases the pointer as must alias, set Must.<br>
+    if (AR == MustAlias)<br>
+      return ModRefInfo::MustModRef;<br>
+  }<br>
</blockquote>
<br>
According to the manual (<a href="http://llvm.org/docs/LangRef.html#id205" rel="noreferrer" target="_blank">http://llvm.org/docs/LangRef.<wbr>html#id205</a>), cmpxchg may or may not write to the location, depending on whether the comparison succeeds. For weak operations, the write may not occur even if the comparison succeeds.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@@ -453,9 +500,17 @@ ModRefInfo AAResults::getModRefInfo(cons<br>
   if (isStrongerThanMonotonic(RMW-><wbr>getOrdering()))<br>
     return ModRefInfo::ModRef;<br>
<br>
-  // If the atomicrmw address does not alias the location, it does not access it.<br>
-  if (Loc.Ptr && !alias(MemoryLocation::get(RMW<wbr>), Loc))<br>
-    return ModRefInfo::NoModRef;<br>
+  if (Loc.Ptr) {<br>
+    AliasResult AR = alias(MemoryLocation::get(RMW)<wbr>, Loc);<br>
+    // If the atomicrmw address does not alias the location, it does not access<br>
+    // it.<br>
+    if (AR == NoAlias)<br>
+      return ModRefInfo::NoModRef;<br>
+<br>
+    // If the atomicrmw address aliases the pointer as must alias, set Must.<br>
+    if (AR == MustAlias)<br>
+      return ModRefInfo::MustModRef;<br>
+  }<br>
<br>
</blockquote>
<br>
According to the manual (<a href="http://llvm.org/docs/LangRef.html#id210" rel="noreferrer" target="_blank">http://llvm.org/docs/LangRef.<wbr>html#id210</a>) not all 'atomicrmw' operations read the pointer. The instruction always writes, but may not read (depending on the underlying operation).<span class="HOEnZb"><font color="#888888"><br>
<br>
Nuno <br>
</font></span></blockquote></div><br></div>