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

    <tr>
        <th>Summary</th>
        <td>
            X86FrameLowering always omits .cfi_restore even when noredzone or win64cc attributes are set
        </td>
    </tr>

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

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

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

<pre>
    If redzone is disabled, the compiler shall not make any assumptions about the contents of the stack beyond the current stack pointer.

However, `llvm::X86FrameLowering::emitEpilogue` does not emit `.cfi_restore` instructions regardless of whether redzone or win64cc are enabled or not; it merely emits `.cfi_def_cfa_offset` instructions.

https://github.com/llvm/llvm-project/blob/2d2da259c8726fd5c974c01122a9689981a12196/llvm/lib/Target/X86/X86FrameLowering.cpp#L2349-L2354

Minimal reproducible example:

```c
int mu(int);

int alpha(int arg)
{
        return mu(arg) ^ mu(arg);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU01vnDAQ_TVwsbIC8-kDh6RJ1ErprYfeosEewI2xkW2y3f76DlClm6iXSsZ4mMfMmzfj3qlL92VgHtUvZ5HpwJQO0BtUCf_E4oRMunnRBj0LExjDrItshhdkYC8MQljnJWpnA4PerfHPHzaijYG5YbdDBPnCerw4qw7A6j0B_jgWpwnvT0l2n2S3x_7ZnfEV_cYhqTNjXuekuKX1va0fPcz4RH6v7Xh8xVnHByLpxhUJzpTDsBPdHFuAkxz0s8cQnd8B2oboV3kQ9ziCVwbDTvg8IVH0b4o4z87a1qWUDDwytLs422dKkBR3jDLM6NFc9mzhLZ3C4VkO8OyGIWD8mPVdtVOMS9hK4Y-0Rh2ntT-R7mTspR-vm8W7Hygjmb1xPb244gp4JWTb8HpQlRRNKbM85xxE3QrR5pDzXNRXcfT23zfwI25xSM5jfyfqSS5LwosnXpTihvaqvCb7VVs9gyGBiI9apSY9GP6EeTG41XAFpaKPJQ-b-szmNeEtHRIuSL1r9OYFs0xwAEjucQMdiOYNKjzG1dsj0IFhSfVwbf8N3Nx_YJKqrlCiEJBGHQ12H2snBme40CTsvbyeG0YDabfxsNT5f01HjF73a6TR2waFep6u3nT_3VtNdwoDHapKiCKduqFQMPRN1mPWyzxvRN82cshzLHlZo4TUQI8mdEl1l3Bu8cz2EHROqvtUdzzjPKtzeniW8VOFZSFL0bS5EnlbDEmZ4QzanDYeJ-fH1Hc7pX4dAzmNDjH8ddKV16NF3NNRfFjj5HynYYZpncGme_JuJ_8blVdmuQ">