<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Registers swapped with -no-integrated-as"
   href="https://llvm.org/bugs/show_bug.cgi?id=22995">22995</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Registers swapped with -no-integrated-as
          </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>Windows NT
          </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>MC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>russell_gallop@sn.scee.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Built from r232944.

Building this example using -no-integrated-as results in a small difference in
the generated code. The register operands of the instruction at 0xc are swapped
compared to direct object emission.

$ cat test.cpp
int a, b;
int fn1();
void fn2() {
  if (a & fn1())
    b = 0;
}
$ clang -c -O2 test.cpp -o direct.o && objdump -d direct.o

direct.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <_Z3fn2v>:
   0:   53                      push   %rbx
   1:   8b 1d 00 00 00 00       mov    0x0(%rip),%ebx        # 7 <_Z3fn2v+0x7>
   7:   e8 00 00 00 00          callq  c <_Z3fn2v+0xc>
   c:   85 c3                   test   %eax,%ebx
   e:   74 0a                   je     1a <_Z3fn2v+0x1a>
  10:   c7 05 00 00 00 00 00    movl   $0x0,0x0(%rip)        # 1a
<_Z3fn2v+0x1a>
  17:   00 00 00
  1a:   5b                      pop    %rbx
  1b:   c3                      retq
$ clang -c -O2 test.cpp -no-integrated-as -o no_int_as.o && objdump -d
no_int_as.o

no_int_as.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <_Z3fn2v>:
   0:   53                      push   %rbx
   1:   8b 1d 00 00 00 00       mov    0x0(%rip),%ebx        # 7 <_Z3fn2v+0x7>
   7:   e8 00 00 00 00          callq  c <_Z3fn2v+0xc>
   c:   85 d8                   test   %ebx,%eax
   e:   74 0a                   je     1a <_Z3fn2v+0x1a>
  10:   c7 05 00 00 00 00 00    movl   $0x0,0x0(%rip)        # 1a
<_Z3fn2v+0x1a>
  17:   00 00 00
  1a:   5b                      pop    %rbx
  1b:   c3                      retq</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>