<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 - probe-stack=inline-asm will produce invalid uwtables"
   href="https://bugs.llvm.org/show_bug.cgi?id=49600">49600</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>probe-stack=inline-asm will produce invalid uwtables
          </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>All
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>simonas+llvm.org@kazlauskas.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given a function as such

; RUN: llc < %s
define void @big_stack() "probe-stack"="inline-asm" uwtable {
start:
  %_two_page_stack = alloca [8192 x i8], align 1
  ret void
}

the following assembly will be generated:

big_stack:
        .cfi_startproc
        subq    $4096, %rsp
        movq    $0, (%rsp)
        subq    $3968, %rsp
        .cfi_def_cfa_offset 8072
        addq    $8064, %rsp
        .cfi_def_cfa_offset 8
        retq


Here the unwind tables are not accurate while stack probing is ongoing – the
`rsp` is adjusted, but not the `cfa_offsets`. And so attempts to obtain a stack
trace will fail if the current instruction is somewhere in between the
instructions implementing the stack probing.

This also occurs with the non-unrolled implementation of the stack probing:

; RUN: llc < %s
define void @big_stack() "probe-stack"="inline-asm" uwtable {
start:
  %_two_page_stack = alloca [64000 x i8], align 1
  ret void
}

--->

big_stack:
        .cfi_startproc
        movq    %rsp, %r11
        subq    $61440, %r11
.LBB0_1:
        subq    $4096, %rsp
        movq    $0, (%rsp)
        cmpq    %r11, %rsp
        jne     .LBB0_1
        subq    $2432, %rsp
        .cfi_def_cfa_offset 63880
        addq    $63872, %rsp
        .cfi_def_cfa_offset 8
        retq

however in the loop case the solution needs to involve allocation of a separate
register as insertion of `.cfi` directives in a loop won't help in any way.</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>