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

Stefan Kanthak via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 5 15:42:40 PDT 2020


STOP POSTING HTML!

> 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!
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. 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



More information about the cfe-dev mailing list