<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 - Inline asm clobber list reserved register warning should point to the clobber list itself"
   href="https://bugs.llvm.org/show_bug.cgi?id=50318">50318</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inline asm clobber list reserved register warning should point to the clobber list itself
          </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>Linux
          </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>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.spickett@linaro.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>(writing this prior to <a href="https://reviews.llvm.org/D102244">https://reviews.llvm.org/D102244</a> landing, so the exact
output may have changed by now)

This applies to all architectures, here's an Arm example.

Test file:
void bar(void)
{
    __asm__ __volatile__ ( "nop" : 
                                 : : "sp");
}

Compile with:
./bin/clang --target=arm-arm-none-eabi -march=armv7-m -c bar.c -o bar.o

You get:
bar.c:3:28: warning: inline asm clobber list contains reserved registers: SP
[-Winline-asm]
    __asm__ __volatile__ ( "nop" :
                           ^
<inline asm>:1:1: note: instantiated into assembly here
        nop
^
bar.c:3:28: note: Reserved registers on the clobber list may not be preserved
across the asm statement, and clobbering them may lead to undefined behaviour.
    __asm__ __volatile__ ( "nop" : : : "sp");
                           ^
<inline asm>:1:1: note: instantiated into assembly here
        nop
^
1 warning generated.

Ideally the warning would point to the clobber list itself. This can be useful
if you use an alias for the reserved register.

E.g. "r13" instead of "sp" on arm. If the user goes to search their file for
"sp" they won't find it, but pointing to the clobber list gives a stronger
hint.

Currently, I think there is only one source location node for the whole inline
asm block and this is why we always mark the start of the block. The clobber
list is its own operand but I don't see a way to get a specific source location
for it.</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>