r191590 - Implements some of the more commonly used intrinsics in Intrin.h

Timur Iskhodzhanov timurrrr at google.com
Wed Oct 2 02:46:37 PDT 2013


2013/10/1 Warren Hunt <whunt at google.com>:
> Yes, we're not presently supporting the usage model where you can simply
> declare the intrinsics like you would for cl.exe.  We had a pretty extensive
> discussion about what constitutes a "builtin" versus what constitutes an
> "intrinsic" and the requirements for headers.  Weirdly in MS world you have
> to declare most "builtins" before you can use them but there are exceptions
> like __debugbreak().  Ultimately we have an agreement that it would be nice
> to support the microsoft intrinsics as builtins (i.e. not require the
> header, and potentially not even a definition) but that will take more work
> plumbing somewhat redundant builtins through clang and it was decided that
> the current approach is both reasonable and expedient.

OK, this looks reasonable.

> Did you find a case in chrome where they are declaring an intrinsic without including "intrin.h"?

Not yet; we do it in the ASan runtime library though as we want to
include as few headers as possible in order to avoid implicit
dependencies from the standard library that might cause bad things
when you intercept/wrap standard functions in the tool.

> On Tue, Oct 1, 2013 at 6:44 AM, Timur Iskhodzhanov <timurrrr at google.com>
> wrote:
>>
>> Please see the comment at
>> http://llvm.org/bugs/show_bug.cgi?id=13283#c5 for the details.
>>
>> For some reason, the value of *_Addend at the end of the function is
>> wrong if we include <intrin.h>;
>> also, it fails to compile if we declare the function without including
>> the header.
>>
>> 2013/10/1 Warren Hunt <whunt at google.com>:
>> > I've tested them under a variety cases.  Are you concerned about the (-
>> > _Value) clause?
>> >
>> > -Warren
>> >
>> >
>> > On Mon, Sep 30, 2013 at 3:58 AM, Timur Iskhodzhanov
>> > <timurrrr at google.com>
>> > wrote:
>> >>
>> >> 2013/9/28 Warren Hunt <whunt at google.com>:
>> >> > +static __inline__
>> >> >  long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long
>> >> > _Value);
>> >> > ...
>> >> > +static __inline__ short __attribute__((__always_inline__,
>> >> > __nodebug__))
>> >> > +_InterlockedExchangeAdd16(short volatile *_Addend, short _Value) {
>> >> > +  return __atomic_add_fetch(_Addend, _Value, 0) - _Value;
>> >> > +}
>> >> > +static __inline__ long __attribute__((__always_inline__,
>> >> > __nodebug__))
>> >> > +_InterlockedExchangeAdd(long volatile *_Addend, long _Value) {
>> >> > +  return __atomic_add_fetch(_Addend, _Value, 0) - _Value;
>> >> > +}
>> >>
>> >> Are you sure this is a correct/complete implementation?
>> >> http://llvm.org/bugs/show_bug.cgi?id=13283#c5
>> >
>> >
>
>



More information about the cfe-commits mailing list