<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 - Assembler operand constraints are ineffective with global register variables"
   href="https://bugs.llvm.org/show_bug.cgi?id=45585">45585</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assembler operand constraints are ineffective with global register variables
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>9.0
          </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>normal
          </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>ubizjak@gmail.com
          </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>Following testcase:

--cut here--
register unsigned long current_stack_pointer asm("rsp");

void
foo (void)
{
  asm volatile ("# %0" :: "a" (current_stack_pointer));
}
--cut here--

compiles on x86 with -O2 to:

        #APP
        # %rsp
        #NO_APP

Please note that the asm uses input operand constraint "a" that would allow
only %rax register.

GCC gets this right and reloads %rsp to %rax:

        movq    %rsp, %rax
#APP
        # %rax
#NO_APP

If the constraint is changed to "r", which allows all general registers,
including %rsp, GCC generates

#APP
        # %rsp
#NO_APP

I'd like to argue that the compiler should reload the input argument, so that
the asm input operand constraint is always respected.</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>