<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59904>59904</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] 16-byte atomic loads using load-pair may not be atomic
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          atdt
      </td>
    </tr>
</table>

<pre>
    With -march=arm8.4-a, clang uses an LDP instruction to do a 16-byte atomic load. According to Arm's documentation, LDP [does not guarantee that all 16 bytes are loaded atomically](https://developer.arm.com/documentation/den0024/a/The-A64-instruction-set/Memory-access-instructions/Memory-access-atomicity) "Load pair and store pair instructions to a pair of general-purpose registers, using an aligned memory address are guaranteed to appear as _two_ individual atomic accesses.". So there may be a risk of tearing when the first 64-bits overflows into the second.

Godbolt link: https://godbolt.org/z/TW3Pb1KG7
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU02vpDYQ_DXm0gIZm2GGAwc2o9lDNtJKibTHVYN7wFljI7d5T5NfH5l5m7xN9sKH265qV3Uhs509US9OH8TpWuCelhB7TCYVYzCP_otNC5QrxmkR-opxvVRNiUL9ApNDP8POxIAePl0_g_Wc4j4lGzykACYAQt2W4yMRYAqrncAFNBUM0xSisX7O24a4CnVmMGHaV_IJ8_lMkCHF6YMJxOBDgnnHiD4RQVowAToHdQsZnQEjHdhk3pjQuYc4XYW6LCltLPQg1E2om6EXcmGjWGFcqymsee1H5pshL6VqhLqhULc_FiqHtinf3a5kSkLdfqM1xEeJ00TM7-v8v-KzKZseQnUglPoU0MCGNgJ6A5xCpOfve5SsDj6Xwx1m8hTRldset8AEkWbLiSJnrXbOaqIHdNlPA-tBD2hMJH7q849-5gDeNsIIyPA1vYavYL2xL9bs6L579WyduBJKVfB7gLRQJFjxASMBQrT8LTeWCGNmf13I5z1wt5ETtE052sQQXijeXXhlsD4dIMA0BW8qIa9CDs_nx2DG4BI4678JPcCPrs3PahXiLNTtr-zKF_15rH_9eC5Mr02nOyyor9uzVp1uZF0s_Zkuyty1kme8qPqi5SiNHGV31hrv96YtbK-k0rKWXd01WtWV1jWSnNqzoVE2tRaNpBWtq5x7WTN3YZl36k9dJ5vC4UiOj-Ao5ekVjqJQKuco9vlMOe4zi0Y6y4n_RUk2uSNxwxCnpW3E6fqznPCbq_m7PKYgS5-TMH7fV-zR9f-RyqZlH98mO1O-vcothj9pynN7NJpn9LjI3wEAAP__nmdY2g">