[Bug target/114968] [14/15 Regression] missing `__thiscall` attribute on builtin declaration of `__cxa_thread_atexit()`

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 8 10:02:56 GMT 2024


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114968

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What is the reason behind
/* mingw32 atexit function is safe to use in shared libraries.  Use it
   to register C++ static destructors.  */
#define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
?
Couldn't we just drop that?
I mean, when using atexit, GCC needs to emit wrapper functions around the
destructors,
like
__tcf_0:
        pushq   %rbp
        .seh_pushreg    %rbp
        movq    %rsp, %rbp
        .seh_setframe   %rbp, 0
        subq    $32, %rsp
        .seh_stackalloc 32
        .seh_endprologue
        leaq    _ZZ3foovE1s(%rip), %rax
        movq    %rax, %rcx
        call    _ZN1SD1Ev
        nop
        addq    $32, %rsp
        popq    %rbp
        ret
while with __cxa_atexit one can just pass the destructor itself to the
__cxa_atexit function (indeed with slightly more instructions there because in
addition to the function pointer it needs to pass the address of the object and
__dso_handle).
But it is still smaller.

Anyway, if there is some strong reason to keep it, I think it would be better
to avoid adding yet another GTY tree, the __cxa_throw last argument type is the
same as __cxa_atexit/__cxa_thread_atexit.


More information about the Gcc-bugs mailing list