<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - __sync_and_fetch_min/max/umin/umax builtins don't support different size overloads"
   href="https://bugs.llvm.org/show_bug.cgi?id=34821">34821</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__sync_and_fetch_min/max/umin/umax builtins don't support different size overloads
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gberry@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>llvm/docs/Atomics.rst lists these builtins as being supported for sizes of 1,
2, 4, 8, or 16, but that doesn't seem to be the case.
For example, on aarch64 where long is 8 bytes:

long atomic64(void) {
  long old;
  long val = 1;
  unsigned long uval = 1;

  old = __sync_fetch_and_min(&val, 3);
  old = __sync_fetch_and_max(&val, 4);
  old = __sync_fetch_and_umin(&uval, 5);
  old = __sync_fetch_and_umax(&uval, 6);

  old = __sync_fetch_and_min_8(&val, 3);
  old = __sync_fetch_and_max_8(&val, 4);
  old = __sync_fetch_and_umin_8(&uval, 5);
  old = __sync_fetch_and_umax_8(&uval, 6);

  return old;
}

generates the following warnings and generates a 32-bit atomic op in the first
case and a function call to an unknown function in the second:

atomic.c:19:30: warning: incompatible pointer types passing 'long *' to
parameter of type 'volatile int *'
      [-Wincompatible-pointer-types]
  old = __sync_fetch_and_min(&val, 3);
                             ^~~~
atomic.c:20:30: warning: incompatible pointer types passing 'long *' to
parameter of type 'volatile int *'
      [-Wincompatible-pointer-types]
  old = __sync_fetch_and_max(&val, 4);
                             ^~~~
atomic.c:21:31: warning: incompatible pointer types passing 'unsigned long *'
to parameter of type
      'volatile unsigned int *' [-Wincompatible-pointer-types]
  old = __sync_fetch_and_umin(&uval, 5);
                              ^~~~~
atomic.c:22:31: warning: incompatible pointer types passing 'unsigned long *'
to parameter of type
      'volatile unsigned int *' [-Wincompatible-pointer-types]
  old = __sync_fetch_and_umax(&uval, 6);
                              ^~~~~
atomic.c:24:9: warning: implicit declaration of function
'__sync_fetch_and_min_8' is invalid in C99
      [-Wimplicit-function-declaration]
  old = __sync_fetch_and_min_8(&val, 3);
        ^
atomic.c:25:9: warning: implicit declaration of function
'__sync_fetch_and_max_8' is invalid in C99
      [-Wimplicit-function-declaration]
  old = __sync_fetch_and_max_8(&val, 4);
        ^
atomic.c:26:9: warning: implicit declaration of function
'__sync_fetch_and_umin_8' is invalid in C99
      [-Wimplicit-function-declaration]
  old = __sync_fetch_and_umin_8(&uval, 5);
        ^
atomic.c:27:9: warning: implicit declaration of function
'__sync_fetch_and_umax_8' is invalid in C99
      [-Wimplicit-function-declaration]
  old = __sync_fetch_and_umax_8(&uval, 6);</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>