<div dir="ltr"><div>Looks like it was deliberately demoted to a warning:</div><div><br></div><div><p style="margin:0px;font-size:12px;font-family:Menlo"><span style="color:rgb(52,187,199)">Sean</span>:~/pg/llvm/tools/clang/include/clang/Basic <span style="color:rgb(195,55,32)">%</span> git log -Swarn_atomic_op_has_invalid_memory_order</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;color:rgb(175,173,36)">commit 7533ae94377aed5aa7866ebd67cbcf616efabb3c</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">Author: Tim Northover <<a href="mailto:tnorthover@apple.com">tnorthover@apple.com</a>></p>
<p style="margin:0px;font-size:12px;font-family:Menlo">Date:   Tue Mar 11 11:35:10 2014 +0000</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    Sema: demote invalid atomic ordering message to warning.</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;min-height:14px">    </p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    Someone could write:</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">      if (0) {</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">        __c11_atomic_load(ptr, memory_order_release);</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">      }</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;min-height:14px">    </p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    or the equivalent, which is perfectly valid, so we shouldn't outright reject</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    invalid orderings on purely static grounds.</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;min-height:14px">    </p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    rdar://problem/16242991</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;min-height:14px">    </p>
<p style="margin:0px;font-size:12px;font-family:Menlo">    git-svn-id: <a href="https://llvm.org/svn/llvm-project/cfe/trunk@203564">https://llvm.org/svn/llvm-project/cfe/trunk@203564</a> 91177308-0d34-0410-b5e6-96231b3b80d8</p></div><div><br></div><div><br></div><div>Tim, could you shed a bit more light on the context of this patch in rdar://problem/16242991 ?</div><div><br></div>-- Sean Silva<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 30, 2015 at 9:48 AM, Ristow, Warren <span dir="ltr"><<a href="mailto:warren_ristow@playstation.sony.com" target="_blank">warren_ristow@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-family:'Courier New'">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">Using the builtin functions for atomic operations that honor the C++11 memory model requirements will result in undefined behavior if an illegal memory model is specified.  Consequently, we can optimize-away
 code that uses the result of one of these incorrectly invoked atomic ops.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">For example, for the function:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  type __atomic_load_n (type *ptr, int memmodel)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">the models __ATOMIC_RELEASE and __ATOMIC_ACQ_REL are not legal.  So in a test-case like:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  int test_good(int* p_atomic, int* p1, int* p2) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    // __ATOMIC_RELAXED memmodel is legal for __atomic_load_n()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int v1 = *p1;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int atomic_val = __atomic_load_n(p_atomic, __ATOMIC_RELAXED);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int v2 = *p2;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    return v1 + v2 + atomic_val;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  int test_bad(int* p_atomic, int* p1, int* p2) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    // __ATOMIC_RELEASE memmodel is illegal for __atomic_load_n()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int v1 = *p1;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int atomic_val = __atomic_load_n(p_atomic, __ATOMIC_RELEASE);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    int v2 = *p2;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">    return v1 + v2 + atomic_val;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">since the 'test_bad()' function is using an illegal memmodel parameter, the behavior is undefined.  Given that that function uses the result ('atomic_val') of that illegal atomic op in the return
 expression, we notice that the return-value of the function is undefined, and therefore at -O2, we legitimately optimize-away anything that feeds into computing that return value.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">Prior to Clang 3.5, this illegal memmodel was accepted without a diagnostic (even with -Weverything).  Beginning with 3.5, we produce:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  warning: memory order argument to atomic operation is invalid<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">So it's now better for users.  But since we freely optimize-away computations that are based on the result of one of these illegal memmodel uses, it seems like it would be reasonable to treat it as
 an error, rather than a warning.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">What do people think?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">FTR, trying this with g++ (version 4.8.2), shows that GNU considers it an error:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">  error: invalid memory model for `__atomic_load'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">-Warren<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">--<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">Warren Ristow<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:'Courier New'">SN Systems - Sony Computer Entertainment Group<u></u><u></u></span></p>
</div>
</div>

<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>