<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 - Incorrect register allocation for inline assembly with 4 outputs"
   href="https://bugs.llvm.org/show_bug.cgi?id=42830">42830</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect register allocation for inline assembly with 4 outputs
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>glider@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling the following code:

$ cat bar.c
char foo();

int bar() {
    char x1 = foo();
    char x2 = foo();
    char x3 = foo();
    char y1, y2, y3, y4;
    asm("mov $1, %k0\nmov $2, %k1\nmov $3, %k2\nmov $4, %k3" : "=r"(y1),
"=r"(y2), "=r"(y3), "=r"(y4));
    return x1 + x2 + y1 + y2 + y3 + y4;
}

with -m32, Clang uses EAX twice to return 1 and 4 from the inline assembly:

$ clang bar.c -c -m32
$ objdump -dr bar.o

00000000 <bar>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   57                      push   %edi
   4:   56                      push   %esi
   5:   83 ec 10                sub    $0x10,%esp
   8:   e8 fc ff ff ff          call   9 <bar+0x9>
                        9: R_386_PC32   foo
   d:   88 45 f7                mov    %al,-0x9(%ebp)
  10:   e8 fc ff ff ff          call   11 <bar+0x11>
                        11: R_386_PC32  foo
  15:   88 45 f6                mov    %al,-0xa(%ebp)
  18:   e8 fc ff ff ff          call   19 <bar+0x19>
                        19: R_386_PC32  foo
  1d:   88 45 f5                mov    %al,-0xb(%ebp)
  20:   b8 01 00 00 00          mov    $0x1,%eax
  25:   b9 02 00 00 00          mov    $0x2,%ecx
  2a:   ba 03 00 00 00          mov    $0x3,%edx
  2f:   b8 04 00 00 00          mov    $0x4,%eax


Without -m32 Clang returns 1 and 4 in EAX and ESI, respectively.</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>