<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVl1vszYU_jXk5ghEgaTJRS6apq0qZeu0dtslMnAC7mswsk2T7tfvGAJJoH03aZYFMcd-zuPzmURmn-utrJzg1gDTP6BEKOQBnkGbpkwEZiArMAXX9EYPHH_r-HenZxDShLcCIWnyS8lu9-cvcOBCgJAso-MITy9vwLJMoSakPTgLP2GKnsArI-0S2ZGeTnBvt1f2Sy1rGH19b8oaaL9F7NF4dT4OCnOuDSrvks4rr1K82ESXIeya7rZXsmzBtGHpD6uGm1aJtloY5EwlLB90eV9c_6-CGYuIxxpTQ5h0sGCEXl1ufuCkRUFrmLLRBlIhk4S-WEqkViqoJHlACDK-3WAYFxYqQWg0oR4IoPMDM0bxpDH4FRs8srIWCKnM8CQg87Uz7dYfktO9pXSCpf3pBCsn3HSiOB6w45jkNCsZp0QKVazZB2Zxb19tz9E8Q1p3niE71bcnYKDxBXh_z0ssu1WhaVR1InlJ0Lndji51ZQK6o2BVDq5rmMrROOGWh8uFK3jVHN28asDd__Z8D27JVFqcpOC-BOC-wp4L9FIr06UVVQbFWUGvzwoHnnZ4Bo9m9Kk9G-vPyrAjubVWuOfH0R6rjt5OEBjUxkvpx2hHThEiwNoVfjas110XNuQYMllTpYZTxlpvXMPVARM8r_p1ZKPOP6788XU-a8ur9ea9E_k9YrfNfg7v4D8MS4uODzzadTBPEs8nhGuldaML-8bs-I0g_U7ARgIbrO09dlQ0ojrppMNqoplKzBWOtzNlPWVI-T_ss9m632s0ED_tXjZ3u_jl8fH14S1-u9vsHii0NxS1HY47KL4M7948Q20cvFZLGzqqq4mTu5Xy45JEdpAqg9oocOYb-kaYmzZnIp-KrTPfTjW2NZSXJWacUYh-wqnEjutg-Hg1f26yiWDirF4wdu9AqS_rlsqh4GlhC2pbDye2GXMb03svB3qTmLwcbee6e97dU7PqXW91xVhlU_97mv99Tgu42OpOMu3fxilhH6oMrpNrUMYzrExbG7p69kH11prgJvR8Sp9JpdDYmWhQEHhkPPSefv3DPTW2wGazfQZdWtdK5gk3-sty-juSOGvSrvnftxw63d4sW4fZKlyxGWtMIdUamf5kuubhTTRrlFgXxtTa2i94pJlT12oSL5UlLYT46F8uKXgn1rTkWjdI7eRxHobB7axYRys_DZfLYJUu5ixa3KySVbZI9r6_8oPlbRrNBEtQ6DVFPV2nwgO0EPZq8-3s_zPg68APAv-GnmEUzX1vwcJ5Ml-ydMHmi5ssIvNhSW3LszieVPlMrVtI-hekSSioQ-qzkGlNdRexJUwMDTcC10OPt1n7bZdtpUdqUrZtUVeiAMxsiM9azuuW8D-DIbv5>53327</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            musttail + no_caller_saved_registers + x86 PIC = bad jmp
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Don't ask me how I stumbled on this one. 

## The bug

LLVM will load the GOT address of `bar` into `eax`, then `pop eax`, then jump to the address in `eax` register.

Since `eax` is popped from the stack, it jumps to a garbage address.

## What is expected to happen

Either LLVM must clobber eax, or not allow musttail to be used with this attribute.

## example code
```c
void foo(void);
__attribute__((no_caller_saved_registers))
void bar(void)
{
    __attribute__((musttail))
    return foo();
}
```

`clang --target=i386-linux-gnu -fPIC -march=i386 -O2 -S file.c -masm=intel`
```asm
        .text
        .intel_syntax noprefix
        .file   "test.c"
        .globl  bar                             # -- Begin function bar
        .p2align        4, 0x90
        .type   bar,@function
bar:                                    # @bar
# %bb.0:
        push    edx
        push    ecx
        push    eax
        call    .L0$pb
.L0$pb:
        pop     eax
.Ltmp0:
        add     eax, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb)
        # load the function pointer into eax
        mov     eax, dword ptr [eax + foo@GOT]
        # then immediately pop eax from the stack?????
        pop     eax
        pop     ecx
        pop     edx
        # then jump to eax which is not a function pointer??????
        jmp     eax                             # TAILCALL
.Lfunc_end0:
        .size   bar, .Lfunc_end0-bar
                                        # -- End function
        .ident  "clang version 13.0.0"
        .section        ".note.GNU-stack","",@progbits
```
Reproduced on Clang 13.0.0.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVtFyqzYQ_Rr8sgODwTjxgx_iOMlkxm06TW77yAhYQLkCMZKInX59V2CwjZPbajTC0kpnz-5qV05k9rneytoJbgww_RMqhFLu4Rm0aatEYAayBlNyTV_0wPG3jn93HIOQOryVCElbnEt2u79-gz0XAoRkGR1HeHp5A5ZlCjUh5eAs_YQpGoHXRtopsgONTnBvt9d2pZENTFbf26oB2m8RBzRen46DwoJrg8o7p_PK6xTPNpExhN2QbbmSVQemDUt_WjXcdEq01cKgYCphxajL-8L8v0tmLCIeGkwNYdLBkhF6fb75gZMWBZ1jqlYbSIVMElqxlEitVFBLioAQ5Hy7wTAuLFSC0GpC3RNAHwdmjOJJa_ArNnhgVSMQUpnhUUDu63razz8kJ7uldIJb-9MJVk646UVxPGLHMcmp1zJOiRSqWLMPzOLBv9qeo36CtOE8Qfaqb47AQO0L8MHOcyy7VaFpVX0keU7QudlOjLpwAdkoWF2A6xqmCjROuOXh7dIVvG4PblG34OZ_PN-DWzGVlkcpuC8BuK-Qc4FeamW6sqLaoDgpGPRZ4cjTNs_gwUyWurOx_qwNO1BYG4U5P0z2WHX0dYLAoDZeSj8mOwq6IQKsX-FXzUbddWFDgSGXtXVqOGWsjcYlXBMwwYt6mC_srfMPK39qzmdjeXXRvHcW_oDYb7PL4R38j2Zp0fGRRzcPoiTxfEK4VNq0urRfzA7fCNLvBGwisJe1s2NHRWPRJL10nF1pphJzgePtTNVcM6T8H_fZbM1zjQbip93L5m4Xvzw-vj68xW93m90DXe0N3doexx0Vn1_vwT1jbRyj1kh7dVRfE69sq-THOYlsL1UGjVHgRBtaI8xNlzMLn4qtE22vNXY1lFcVZ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