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

    <tr>
        <th>Summary</th>
        <td>
            clang-cl generates unnecessary stack read/write instructions
        </td>
    </tr>

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

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

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

<pre>
    Build the following with clang18.1.1 with this command `clang-cl c.cpp --target=aarch64-pc-windows-msvc /c /O2 /FA`.
```
#include <windows.h>

extern "C"
int
WINAPI
CompareStringExStub(
    __in_opt LPCWSTR lpLocaleName,
    __in DWORD dwCmpFlags,
    __in_ecount(cchCount1) LPCWCH lpString1,
    __in int cchCount1,
    __in_ecount(cchCount2) LPCWCH lpString2,
    __in int cchCount2,
    __in_opt LPNLSVERSIONINFO lpVersionInformation,
    __in_opt LPVOID lpReserved,
    __in_opt LPARAM lParam
)
{
    return CompareStringEx(
 lpLocaleName,
                         dwCmpFlags,
 lpString1,
                         cchCount1,
 lpString2,
                         cchCount2,
 lpVersionInformation,
                         lpReserved,
 lParam
 );
}
```

In the generated code, see below, `ldr x9, [sp]` and `str x9, [sp]` are not needed.
```
CompareStringExStub: // @CompareStringExStub
// %bb.0:
        adrp    x8, __imp_CompareStringEx
        ldr     x8, [x8, :lo12:__imp_CompareStringEx]
        ldr     x9, [sp]
        str     x9, [sp]
        br      x8
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVV1vqzgQ_TXOyygIDKThgYckFG2kblu1q_YxMvYEvGtsZJum99-vIOT2i_ZakTNm5gyeczyGOSdrjZiTdEvSYsF63xibt_woF5URv_JtL5UA3yAcjVLmJHUNJ-kb4IrpOloHURCdH_hGOuCmbZkWQFbhGLDkCnjAuw6WS89sjZ7EBWOWN6tk2fHlSWphTm7ZuhcOhJbjdEeHudyQVRiQsCDhYE2_85LGUnPVCwQS76YcQUPi68k_zvjq0WoglO4IpednUvuz8by_3dzvz_bOtB2z-Oit1PX166PvK0LXZx8AwOEg9cF0Hm7ud8-P_zyA6m4MZwpvWYuE7j5GQvF891CAOO3arlSsdl8iDshNrz2ha86b3WBGhGZj9t1foLrzRqKvmaX28A7yx7R0Ji39Oe1X91T57c3j0_XD4_7udn9b3oHqntA6afReH41tmZdGfwd9utsXoLoHdGhfUHwXtnnY_A3qnlnWXmTOJuNq-4aw6Hur4ZNob4J9K87smJNpXoHZMaPGPNE_oul79B94nR1z5L5nEgYq4-2FzWK-q8Z5r8dur1GjZR4FcCMGHsEhQoXKnIYFWYVKWHjNxkW6dR1JC7IKYWp-52edFkEbDxpRoJjv7blmjIcCSkJLIEk4FzAdl3MITasqCEm8uZSVMWE7Emav62FDh4Nsu8Pn43MJVcL-jiTpdjLijTIRJfFmHpwWn_EfS784nf_BWU0v_kjKQuSxyOKMLTCPriKaZgldJ4smD-kxTRljIonYlUiP0YrSLF7RLOYYc0wWMqchTcIkXEereB0mAcVjcoyRc16tUkErkoTYMqkCpV7awNh6IZ3rMV-vw4guFKtQufG7QKnGE4zO4SJNi4XNB8yy6mtHklBJ591bFi-9wvz39X85SQ56rZGjc8z-AucZ_w8sMkFoebLSI0jtvO35cOLdorcqb7zv3KDjKGwtfdNXATctoeXwsulv2VnzL3JPaDlu0RFajiX8HwAA__9oLf6v">