[cfe-dev] BUG: complete misunterstanding of the MS-ABI

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Sun Sep 13 10:15:43 PDT 2020


On Sun, 6 Sep 2020 at 12:30, Stefan Kanthak via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> STOP POSTING HTML!
>

Please don't come into our mailing list and post rude messages and demand
that we conform to your expectations of mailing list etiquette. HTML mails
are fine here. Your repeated rude comments are not. Please take a minute to
decide whether you want to participate in our community or not; if you do,
please try to follow our communication norms.

> Le 5 sept. 2020 à 23:42, Stefan Kanthak <stefan.kanthak at nexgo.de> a écrit
> :
>
> [...]
>
> > The clang version is fine,
>
> WRONG: it violates the MS-ABI!
>

No, it doesn't. The __int128 type is a clang extension, and as such the MS
ABI specification does not cover its ABI. If you want ABI compatibility
between two compilers, you need to use the same types in both cases. You
didn't -- you used __int128 on the Clang side and a struct on the MS ABI
side -- so you broke the rules, and you can't expect ABI compatibility.


> Remember: it's clang that claims to be compatible with a specification
> written and implemented by Microsoft!
>
> > this the the MSVC version that define a type using a compiler reserved
> name and make
> > assumptions about it.
>
> ARGH, again: MSVC is not the problem here, but clang!
> It doesn't matter whether the user-defined type is named __uint128_t or
> dummy,
> MSVC generates exactly the same code, ALWAYS:
>
> --- clang-bug-demo.c ---
> #ifndef __clang__
> typedef struct {
>     unsigned __int64 low;
>     unsigned __int64 high;
> } dummy;
> #else
> #define dummy __uint128_t
> __attribute__((ms_abi))
> #endif
> dummy __udivmodti4(dummy dividend, dummy divisor, dummy *remainder) {
>     if (remainder != 0)
>         *remainder = divisor;
>     return dividend;
> }
> --- EOF ---
>
> >> Again: start to read what I already posted!
> >> I use clang's own __uint128_t data type and show the assembly it
> generates,
> >> which is but INCOMPATIBEL with the MS-ABI.
> >
> > And this is perfectly legit.
>
> WRONG!
>
> > As the MS-ABI does not support the __int128 type, using it with MSVC is
> an undefined behaviour.
>
> The MS-ABI supports user-defined types.


As has been explained, __int128 is not a user-defined type. It's a scalar
integer type.


> And specifies EXPLICITLY how to
> handle them when used as return value that doesn't fit in RAX..
> clang claims to be compatible, but this is a BLATANT LIE!
>
> Stefan
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200913/e233dd08/attachment-0001.html>


More information about the cfe-dev mailing list