<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 - Invalid aarch64 instruction related to __int128"
   href="https://bugs.llvm.org/show_bug.cgi?id=50678">50678</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid aarch64 instruction related to __int128
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jean-philippe@linaro.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24942" name="attach_24942" title="Small reproducer causing invalid aarch64 instruction generation with -no-integrated-as">attachment 24942</a> <a href="attachment.cgi?id=24942&action=edit" title="Small reproducer causing invalid aarch64 instruction generation with -no-integrated-as">[details]</a></span>
Small reproducer causing invalid aarch64 instruction generation with
-no-integrated-as

When building the attached reproducer with:

clang --target=aarch64-linux-gnu --sysroot=/usr/aarch64-linux-gnu
--gcc-toolchain=/usr -no-integrated-as -o reprod-clang-no-ias reprod.c

I get the following error:

/tmp/reprod-f81ff0.s: Assembler messages:
/tmp/reprod-f81ff0.s:52: Error: operand 1 must be an integer register -- `mrs
d0,NZCV'
clang-13: error: assembler command failed with exit code 1 (use -v to see
invocation)

The invalid instruction seems to show up when passing a __int128 cast to
uint64_t as Nth argument to printf, where N is large enough to exceed the
number of register parameters.

I use clang from the git repo (clang version 13.0.0
(<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
22f194909ae24aed817976fb54b759550e90db36))

When built with -integrated-as, the resulting binary contains a valid 'mrs
x0,NZCV' instruction. However, on the original test case (Linux BPF selftests),
the binary generated with -integrated-as segfaults somewhere within that printf
call:

Stack trace:
./test_progs(crash_handler+0x2c)[0x4fc60c]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffffaa675850]
/lib/libc.so.6(+0x6e2b8)[0xffffaa48b2b8]
/lib/libc.so.6(__snprintf+0x70)[0xffffaa469ba0]
./test_progs(get_pprint_expected_line+0x3e4)[0x428ff8]
./test_progs[0x42f5f4]
./test_progs[0x42c458]
./test_progs(test_btf+0x10c)[0x429134]
./test_progs(main+0x248)[0x4fc948]
/lib/libc.so.6(__libc_start_main+0xc4)[0xffffaa441994]
./test_progs[0x40d0b4]
Segmentation fault

I'm guessing that error is related since it's in the same location as the one
reported here, but I'm still trying to reproduce it with a simpler case.</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>