<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 - LLDB AArch64 SVE register context fails to restore after JITTed expression eval"
   href="https://bugs.llvm.org/show_bug.cgi?id=51451">51451</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB AArch64 SVE register context fails to restore after JITTed expression eval
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.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>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>omair.javaid@linaro.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Used add_int_arrays_acle example from here:
<a href="https://www.linaro.org/blog/how-to-use-lldb-to-debug-sve-enabled-applications/">https://www.linaro.org/blog/how-to-use-lldb-to-debug-sve-enabled-applications/</a>

Used instructions to run on qemu with ubuntu focal where I installed clang-12
and lldb-12 using "apt install".

If I put a breakpoint in the middle of add_int_arrays_acle function, I can read
the SVE registers with "re re". But if I try to read a C variable, the SVE
registers get modified. Here is an example:

Process 298 stopped
* thread #1, name = 'test', stop reason = breakpoint 1.1
    frame #0: 0x000000000040058c
test`add_int_arrays_acle(out=0x000000000041102c, a=0x000000000041302c,
b=0x000000000041502c) at arrays.c:17:3
   14  
   15     pred = svwhilelt_b32(i, (uint64_t)ARRAYSIZE);
   16  
-> 17     while (svptest_first(svptrue_b32(), pred)) {
          ^
   18       sva = svld1(pred, &a[i]);
   19       svb = svld1(pred, &b[i]);
   20       svres = svadd_m(pred, sva, svb);
(lldb) re re p0
      p0 = {0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x11}
(lldb) p i
(uint64_t) $1 = 0
(lldb) re re p0
      p0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
(lldb)

I have used the p* registers above as the effect is not visible in the z*
registers unless they have data in the high bits. Here is the example:

(lldb) re write z0 "0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f
0x2f 0x2f 0x2f 0x2f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x01 0x01"

(lldb) re re z0
      z0 = {0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f
0x2f 0x2f 0x2f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x01 0x01}
(lldb) p i
(uint64_t) $2 = 0
(lldb) re re z0
      z0 = {0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f
0x2f 0x2f 0x2f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00}
(lldb)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>