<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55317>55317</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            how to remove unnecessary prologue for noreturn function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zq1997
      </td>
    </tr>
</table>

<pre>
    If the function never returns, saving the callee-save registers is unnecessary. Then, how to disable these `push`s?

```c
// noreturn.c
int bar(int, int, int);

__attribute__ ((noreturn)) int foo(int a, int b, int c) {
    bar(bar(a, a, a), bar(b, b, b), bar(c, c, c));
    while(1) {}
}
```

```sh
clang -c -O3 -fno-unwind-tables noreturn.c
objdump -d noreturn.o
```

```
0000000000000000 <foo>:
   0:   55                      push   %rbp     <- unnecessary
   1:   41 56                   push   %r14     <- unnecessary
   3:   53                      push   %rbx     <- unnecessary
   4:   89 d3                   mov    %edx,%ebx
   6:   89 f5                   mov    %esi,%ebp
   8:   89 fe                   mov    %edi,%esi
   a:   89 fa                   mov    %edi,%edx
   c:   e8 00 00 00 00          call   11 <foo+0x11>
  11:   41 89 c6                mov    %eax,%r14d
  14:   89 ef                   mov    %ebp,%edi
  16:   89 ee                   mov    %ebp,%esi
  18:   89 ea                   mov    %ebp,%edx
  1a:   e8 00 00 00 00          call   1f <foo+0x1f>
  1f:   89 c5                   mov    %eax,%ebp
  21:   89 df                   mov    %ebx,%edi
  23:   89 de                   mov    %ebx,%esi
  25:   89 da                   mov    %ebx,%edx
  27:   e8 00 00 00 00          call   2c <foo+0x2c>
  2c:   44 89 f7                mov    %r14d,%edi
  2f:   89 ee                   mov    %ebp,%esi
  31:   89 c2                   mov    %eax,%edx
  33:   e8 00 00 00 00          call   38 <foo+0x38>
  38:   0f 1f 84 00 00 00 00    nopl   0x0(%rax,%rax,1)
  3f:   00 
  40:   eb fe                   jmp    40 <foo+0x40>
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVsuOpCAU_RrdECs8fC5c9KuSWc1m9h1ELO1YUiNabc_XDyii3faUlYwxgBfOuZfDFchE_pH-KEBXclD0Desq0YCGX3kLWt71bSMd_AQkvVbNaRzEaF1z7ikLVyNOlex4K0ElQd80nHEpaftxAL9K3mhgKd5BJ0BeSZrVXBNIDpwQXnpZqko65OjAZwc-mDKE08vMNz6qFzRiiuVgzFXTgYy2Do5VS7tZV4lDHtecr6-069oq6zv--goURr0zoR6NE40DhRATH6CGCmRzg-lBTmRogXom71M5jp-LRNemd2yaYmVnujkXyTpgzfxeVjVXo9DsM3o2s7GNWaRvlVO6jgZWU7ViHgPeTwK8ohFe37xXTe51eiXkRlORveX9-QK8fOkS9zicPuGXBzjkSUtKXhzyYGcHx48kCMD2UXadFbqFgza7TEby5K0zyzKhiclHIAhvMyH_NhMxMZH9mIbbTP7EFCcg35Ap-1lcwcTE80Etv25kg0WHFl1s5PmMltWMvlh0vKD5ju8ZrWhmNF3Q9E50vkTOJjSPgVp3-1q03jH0iqE5J_AjHBDSqWEY0LKaKgQW3vBPjXJqWXMLX4Tnxe3wlWImfDt5tAjPd6Sz6EU6tAjPd6RbfFvpEL1PuuKTdMVausL6ZztpQ4dN2mC0pOyecsNGOUwW9J5yw0Y5HCzoPeWGjXI4uks5zNbKYbZSDpu09X2ddEX0b_9jrm0mX_xP2pBFeIbvXLZl8oTcNXkSrydP4tXkiUlbWOjkiv1PPMreiItmgAMcD8ygtf_d2NCHk6UyQozAyeSbfZ5n3-9Gb-dxd_fhOj4Nevlytrh5SvKEJNTtqq7mqblOtFzpw9d7MLi0ohanXl1iRGsPMHujcfu2Tsuuu0gd2HipOFVd2WcHJs7qo66vc-UppjfO1EXiWEnZc3X_OQYBQZFbphGOoc8yhgsSJJAxiFiMs4hFNFQHCIZuTTNey9QJHp3g2a1SDDGGAYyQTwgMDzTMEoYimhFOKM6x40N-plV90I4Poj25bTrGkPUnqTprdbuSSyeVsjo1nM_8tO9K0aZ_fqMkidwx2nQM9S8Ox3Vi">