<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 - Missed opportunity to use tail calls"
   href="https://bugs.llvm.org/show_bug.cgi?id=50117">50117</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed opportunity to use tail calls
          </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>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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>void foo (char *, int n);
int bar (int);
int baz (char *p);

int
test1 (int n)
{
  {
    char buf[64];
    foo (buf, n);
  }
  return bar (n);
}

void
test2 (char *p)
{
  {
    char c;
    baz (&c);
  }
  baz (p);
}

test1:                                  # @test1
        push    rbx
        sub     rsp, 64
        mov     ebx, edi
        mov     rdi, rsp
        mov     esi, ebx
        call    foo
        mov     edi, ebx
        call    bar // can be jmp bar
        add     rsp, 64
        pop     rbx
        ret
test2:                                  # @test2
        push    rbx
        sub     rsp, 16
        mov     rbx, rdi
        lea     rdi, [rsp + 15]
        call    baz
        mov     rdi, rbx
        call    baz // can be jmp baz
        add     rsp, 16
        pop     rbx
        ret


<a href="https://godbolt.org/z/TvM81eYod">https://godbolt.org/z/TvM81eYod</a>

In IR I see that we have just call, not "tail call", so a middle-end issue.</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>