<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 - Wrong CFI metadata for registers spilled in prolog"
   href="https://bugs.llvm.org/show_bug.cgi?id=49663">49663</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong CFI metadata for registers spilled in prolog
          </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>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>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>Consider the following snippet (<a href="https://llvm.godbolt.org/z/cTr35q">https://llvm.godbolt.org/z/cTr35q</a>):

    target triple = "i686"

    define void @no_availble_registers_many_args(i32 %a, i32 %b, i32 %c, i32
%d) "no_caller_saved_registers" {
    %all = alloca i32, i64 18000
    %ab = add i32 %a, %b
    %cd = add i32 %c, %d
    %abcd = add i32 %ab, %cd
    %b0 = getelementptr inbounds i32, i32* %all, i64 98
    store volatile i32 %abcd, i32* %b0
    ret void
    }

This produces the following assembly in the prologue:

        .cfi_startproc
        pushl   %ecx
        .cfi_def_cfa_offset 8
        pushl   %eax
        .cfi_def_cfa_offset 12
        subl    $72000, %esp                    # imm = 0x11940
        .cfi_def_cfa_offset 72012
        .cfi_offset %eax, -12
        .cfi_offset %ecx, -8

Here we set the `.cfi_offset` for the spilled registers (eax, ecx) too late and
to the wrong offsets on the stack.

These `.cfi` directives would've been correct if they were emitted immediately
after the `push` instruction, but with the huge allocation on the stack, we
actially `.def_cfa_offset` first, thus changing the offsets entirely, and
making these directives incorrect.</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>