| Issue |
88012
|
| Summary |
clang-cl generates unnecessary stack read/write instructions
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
mcfi
|
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
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs