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

    <tr>
        <th>Summary</th>
        <td>
            Default semantics of `syncscope("system")` missing in the langref
        </td>
    </tr>

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

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

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

<pre>
    In multiple places throughout the llvm codebase, it is assumed that `syncscope("system")` is the default.

As an example, when an atomic operation is created with `syncscope("system")` printing it omits that syncscope.
https://github.com/llvm/llvm-project/blob/8a229f595a5c0ff354cdfa05cda974a9d56674df/llvm/lib/CodeGen/MachineOperand.cpp#L530-L531

When creating an atomic load instruction without a syncscope specifiy it is assumed to be `system` https://github.com/llvm/llvm-project/blob/8a229f595a5c0ff354cdfa05cda974a9d56674df/llvm/lib/IR/Instructions.cpp#L1271-L1275

This default nature of `system` should be documented in the language reference, where currently only `target-specific` (e.g. what backends like AMDGPU have) and `single-threaded` exist.

A wrinkle is the PTX backend. PTX does mostly use NVVM intrinsics, but also some LLVM atomic operations.
Eventually, I would love to see a move away from the nvvm intrinsics and instead fully use the LLVM atomic operation,
but currently PTX does not handle syncscopes and thus "mistranslates" the `syncscope("system")` to the PTX syncscope `device`...

This essentially means that there is an ambiguity between `syncscope("system")` and the syncscope being left undefined.
I wanted to start work on supporting atomics with a syncscope argument in the PTX backend, but this conflict in defaults would potentially break users who have been emitting atomic operations on PTX. To be clear, it would be a performance issue and not a semantic one. 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VU9v47YT_TT0ZRBBoiw7OviQ3-bnRYCkXRRputcROZLYUKTAoaz1ty8o27H7B-320osMGeLMe2_ePCKz6RzRTlT_E9XjCqfY-7A7qH4KeDiuGq-PuycHw2SjGS3BaFERQ-yDn7reTxFiT2DtYQDlNTXIJOQnMBEM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