bcl5980 added a comment.

Another thing we need consider here is this case:

  #pragma pack(push, 1)
      struct b64 {
          char a[64];
      };
  #pragma pack(pop)
  
      typedef b64 (fptrtype)(int a);
  
      b64 f(void* p, int a) {
          return ((fptrtype*)p)(a);
      }

For now we generate exit_thunk with type void f(void* sret(b64) ret, int a)

  $iexit_thunk$cdecl$v$i8i8:              // @"$iexit_thunk$cdecl$v$i8i8"
  .seh_proc $iexit_thunk$cdecl$v$i8i8
  // %bb.0:
        sub     sp, sp, #48
        .seh_stackalloc 48
        stp     x29, x30, [sp, #32]             // 16-byte Folded Spill
        .seh_save_fplr  32
        add     x29, sp, #32
        .seh_add_fp     32
        .seh_endprologue
        mov     w1, w0
        mov     x0, x8
        adrp    x8, __os_arm64x_dispatch_call_no_redirect
        ldr     x8, [x8, :lo12:__os_arm64x_dispatch_call_no_redirect]
        blr     x8
        .seh_startepilogue
        ldp     x29, x30, [sp, #32]             // 16-byte Folded Reload
        .seh_save_fplr  32
        add     sp, sp, #48
        .seh_stackalloc 48
        .seh_endepilogue
        ret
        .seh_endfunclet
        .seh_endproc
                                          // -- End function
        .globl  f
        .def    f;
        .scl    2;
        .type   32;
        .endef

But it looks Microsoft generate exit thunk with type void* f(int a)

  |$iexit_thunk$cdecl$i8$i8| PROC
  |$LN2|
        pacibsp
        stp         fp,lr,[sp,#-0x10]!
        mov         fp,sp
        sub         sp,sp,#0x20
        adrp        x8,__os_arm64x_dispatch_call_no_redirect
        ldr         xip0,[x8,__os_arm64x_dispatch_call_no_redirect]
        blr         xip0
        mov         x0,x8
        add         sp,sp,#0x20
        ldp         fp,lr,[sp],#0x10
        autibsp
        ret
  
        ENDP  ; |$iexit_thunk$cdecl$i8$i8|

But based on clang x86 on Windows, we also generate the function type with void 
f(void* sret(b64) ret, int a).
It looks clang is different from MSVC even in x86 ABI.
Do we need to follow MSVC to generate $iexit_thunk$cdecl$i8$i8 ? Or just follow 
clang's ABI and ignore the difference?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125418

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to