<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:t.p.northover@gmail.com" title="Tim Northover <t.p.northover@gmail.com>"> <span class="fn">Tim Northover</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Incorrect barriers for legacy __sync_* on ARM64"
   href="https://bugs.llvm.org/show_bug.cgi?id=29102">bug 29102</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Summary</td>
           <td>Incorrect barriers for atomic intrinsics on ARM64
           </td>
           <td>Incorrect barriers for legacy __sync_* on ARM64
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Component</td>
           <td>new bugs
           </td>
           <td>LLVM Codegen
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>INVALID
           </td>
           <td>---
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Product</td>
           <td>new-bugs
           </td>
           <td>clang
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Assignee</td>
           <td>unassignedbugs@nondot.org
           </td>
           <td>unassignedclangbugs@nondot.org
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>richard-llvm@metafoo.co.uk
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Incorrect barriers for legacy __sync_* on ARM64"
   href="https://bugs.llvm.org/show_bug.cgi?id=29102#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Incorrect barriers for legacy __sync_* on ARM64"
   href="https://bugs.llvm.org/show_bug.cgi?id=29102">bug 29102</a>
              from <span class="vcard"><a class="email" href="mailto:t.p.northover@gmail.com" title="Tim Northover <t.p.northover@gmail.com>"> <span class="fn">Tim Northover</span></a>
</span></b>
        <pre>I've just been reading through the Mono history & comments, and it's convinced
me to reopen this.

The issue is specifically with the legacy __sync_* operations. Those *do*
appear to give extra barriers on AArch64 GCC, and the documentation (while
written in horribly vague pre-C++11 terms) could be read to require them -- see
<a href="https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html">https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html</a>.

GCC codegen for a generic loop is roughly:

    .L2:
        ldxr    w1, [x0]
        add     w1, w1, 4
        stlxr   w2, w1, [x0]
        cbnz    w2, .L2
        dmb     ish

This is also what Will implemented (and justified) in the referenced GCC thread
on the Linux Kernel.

No matter what, this will involve Clang changes. There's a reasonable chance it
could be implemented entirely in Clang (as an "atomicrmw release" followed by a
fence) but I haven't thought in enough detail to convince even myself.
Otherwise it would need the new super_seq_cst above, and also Clang changes to
use it -- so I've put this in the Clang component.

Priority may also be an issue. This requires strong expertise and interest in
the topic. That may be difficult to drum up for legacy intrinsics.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>