<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 - __builtin_frame_address(0) returning RSP for x86_64-windows (instead of RBP)"
   href="https://bugs.llvm.org/show_bug.cgi?id=51713">51713</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_frame_address(0) returning RSP for x86_64-windows (instead of RBP)
          </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>enhancement
          </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>xtkoba@gmail.com
          </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=25219" name="attach_25219" title="Repro">attachment 25219</a> <a href="attachment.cgi?id=25219&action=edit" title="Repro">[details]</a></span>
Repro

$ cat frameaddr.c

void bar(int *n);

void foo(int **p, int n)
{
  __asm__ __volatile__ ("nop");
  *p = __builtin_frame_address(0);
  __asm__ __volatile__ ("nop");
  bar(&n);
}

$ clang --target=x86_64-windows frameaddr.c -c -o - | llvm-objdump -d -

<stdin>:        file format coff-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
       0: 55                            pushq   %rbp
       1: 48 83 ec 30                   subq    $48, %rsp
       5: 48 8d 6c 24 30                leaq    48(%rsp), %rbp
       a: 89 55 fc                      movl    %edx, -4(%rbp)
       d: 48 89 4d f0                   movq    %rcx, -16(%rbp)
      11: 90                            nop
      12: 48 8d 4d d0                   leaq    -48(%rbp), %rcx
      16: 48 8b 45 f0                   movq    -16(%rbp), %rax
      1a: 48 89 08                      movq    %rcx, (%rax)
      1d: 90                            nop
      1e: 48 8d 4d fc                   leaq    -4(%rbp), %rcx
      22: e8 00 00 00 00                callq   0x27 <foo+0x27>
      27: 90                            nop
      28: 48 83 c4 30                   addq    $48, %rsp
      2c: 5d                            popq    %rbp
      2d: c3                            retq

The instruction "leaq -48(%rbp), %rcx" at 0x12 should instead be something like
"movq %rbp, %rcx".

I don't know whether this is expected, but this behavior breaks
__builtin_longjmp for x86_64-windows (PR50142).</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>