[PATCH] D125418: [Arm64EC 6/?] Implement C/C++ mangling for Arm64EC function definitions.

chenglin.bi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 00:10:18 PDT 2022


bcl5980 added a comment.

In D125418#3759174 <https://reviews.llvm.org/D125418#3759174>, @efriedma wrote:

> The reason struct returns require register shuffling is that AArch64 passes the sret pointer in x8 (i.e. RAX), but the x64 calling convention expects in in RCX (i.e. x0).

So, for the function: s64 f(int a):
AArch64 CC:    void f(x8, x0)
X64 CC:            void f(rcx[x0], rdx[x1])
AArch64 --> X64 we need to add instructions before blr

  mov x1, x0
  mov x0, x8

It can match `iexit_thunk$cdecl$m64$i8` when we call extern function not a function pointer.

> Have you tried to see if the Microsoft-generated thunk actually works?  I found at least one bug in MSVC thunk generation and reported it to Microsoft.  (Microsoft didn't acknowledge the report, but that's a different story...)

You are right. For now, I haven't tested too much case runtime. But it looks if a DLL import function pass to a function pointer, then call it will cause access violation.
Based on the debug result, it should be exit thunk issue, MSVC generate wrong thunk type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125418/new/

https://reviews.llvm.org/D125418



More information about the cfe-commits mailing list