<div dir="ltr">We should fix it. We just need a new character code in the builtin function prototype encoding. Currently there is no encoding for a portable int32_t that magically becomes "long" on 32-bit Windows. The closest thing we have is 'W', which is used by Neon intrinsics to select between "long" and "long long". It was added in r202004.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert <span dir="ltr"><<a href="mailto:eriksc@microsoft.com" target="_blank">eriksc@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We (Office developers for Apple platforms at Microsoft) would prefer to have the intrinsics work properly for LP64, as that will generate the most optimal and efficient code. That said, we understand that this may be odd to implement from the compiler's perspective and can work around it if the intrinsics are not supported for ms-extensions+LP64. At the end of the day we need the compiler to clearly adopt one of those two options, and not sit somewhere in the middle as it currently does. We don't turn on any flags other than -fms-extensions; we don’t attempt to define MSC_VER and we do conditionalize code based on __clang__ so the code is aware it is being compiled by clang vs MSVC.<br>
<br>
So I think we'd prefer what Duncan and Apple are offering to do, but if the larger clang community thinks that is a bad idea and wants to explicitly disable the intrinsics, we could live with that.<br>
<br>
Thanks,<br>
Schwieb<br>
<span class="im HOEnZb"><br>
-----Original Message-----<br>
From: Erik Schwiebert<br>
Sent: Friday, June 16, 2017 8:49 AM<br>
To: 'Bruno Cardoso Lopes' <<a href="mailto:bruno.cardoso@gmail.com">bruno.cardoso@gmail.com</a>>; Brian Kelley <<a href="mailto:bkelley@microsoft.com">bkelley@microsoft.com</a>>; Tomasz Kukielka <<a href="mailto:tkukielk@microsoft.com">tkukielk@microsoft.com</a>><br>
Cc: <a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>; Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>>; cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>><br>
</span><div class="HOEnZb"><div class="h5">Subject: RE: r284060 - Implement MS _BitScan intrinsics<br>
<br>
Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK intrinsics headers. I'm not sure which method we'd prefer, so I'll walk down the hall and ask them. Tomasz is our header maestro (because we play crazy #include_next games so we can use both Windows and macOS SDKs!)<br>
<br>
We'll get back to you ASAP.<br>
<br>
Schwieb<br>
<br>
-----Original Message-----<br>
From: Bruno Cardoso Lopes [mailto:<a href="mailto:bruno.cardoso@gmail.com">bruno.cardoso@gmail.<wbr>com</a>]<br>
Sent: Thursday, June 15, 2017 4:41 PM<br>
To: Erik Schwiebert <<a href="mailto:eriksc@microsoft.com">eriksc@microsoft.com</a>><br>
Cc: <a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>; Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>>; cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>><br>
Subject: Re: r284060 - Implement MS _BitScan intrinsics<br>
<br>
On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes<br>
<<a href="mailto:bruno.cardoso@gmail.com">bruno.cardoso@gmail.com</a>> wrote:<br>
> On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits<br>
> <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>> SGTM too. Regarding Duncan's last question -- I can't think of any such customer. :) If you all think the right thing for clang to do is to infer LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!<br>
<br>
Thinking more about this; what if we mark such builtins as unsupported<br>
for "LP64 (Darwin) + ms_extensions" and then you provide the<br>
definitions via intrin.h (we can generate a compiler macro for this<br>
scenario and conditionalize the include_next as we do for _MSC_VER)?<br>
Do you use this header at all? Are there any other MS related flags<br>
that get passed to the compiler?<br>
<br>
> SGTM as well!<br>
><br>
>><br>
>> Thanks all!<br>
>> Schwieb<br>
>><br>
>> -----Original Message-----<br>
>> From: <a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a> [mailto:<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>]<br>
>> Sent: Monday, June 12, 2017 1:55 PM<br>
>> To: Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>><br>
>> Cc: Saleem Abdulrasool <<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>>; Albert Gutowski <<a href="mailto:agutowski@google.com">agutowski@google.com</a>>; David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>>; cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>>; Erik Schwiebert <<a href="mailto:eriksc@microsoft.com">eriksc@microsoft.com</a>><br>
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics<br>
>><br>
>><br>
>>> On Jun 12, 2017, at 12:44, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
>>><br>
>>>> On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool <<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>> wrote:<br>
>>>> I'm worried about changing this signature all the time.  I suspect that it will cause the following to be emitted for valid code:<br>
>>>><br>
>>>> warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'unsigned int *' [-Wincompatible-pointer-types]<br>
>>>><br>
>>>> Switching the signature on LP64 sounds much better to me.<br>
>>><br>
>>> Right, we have to do this. It needs to be `long` on Windows.<br>
>><br>
>> SGTM.  We'll go that way.<br>
><br>
> +1 here!<br>
><br>
>>> On Jun 8, 2017, at 12:21, Erik Schwiebert <<a href="mailto:eriksc@microsoft.com">eriksc@microsoft.com</a>> wrote:<br>
>>><br>
>>> It’s probably also better to not try to infer our weird desired behavior. It should probably be controlled by a specific driver directive, like “-fms-extensions-lp64-<wbr>intrinsics” or something like that. Using a new directive means that nobody can accidentally get this behavior if they for some reason do want LLP64 behavior with Windows intrinsics.<br>
>><br>
>> This seems overly complicated.  Is there a customer that:<br>
>> - is on LP64,<br>
>> - is using -fms-extensions,<br>
>> - is using these intrinsics, and<br>
>> - wants them to be 64-bit longs instead of 32-bit ints?<br>
>> Put another way: who would use these intrinsics on LP64 and *not* want to mimic LLP64?<br>
>><br>
>> If everyone using the intrinsics on LP64 is going to have to specify -fms-extensions-lp64-<wbr>intrinsics, then we should just imply it.<br>
>> ______________________________<wbr>_________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fcfe-commits&data=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946&sdata=iWTF3jpX71tU%2B6aq%2BEpv8VD8IFfeDKMHvZd40%2FK64aE%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Flists.llvm.org%<wbr>2Fcgi-bin%2Fmailman%<wbr>2Flistinfo%2Fcfe-commits&data=<wbr>02%7C01%7Ceriksc%40microsoft.<wbr>com%<wbr>7Cba4835eb4a1b438793d508d4b448<wbr>1355%<wbr>7C72f988bf86f141af91ab2d7cd011<wbr>db47%7C1%7C0%<wbr>7C636331669036098946&sdata=<wbr>iWTF3jpX71tU%2B6aq%<wbr>2BEpv8VD8IFfeDKMHvZd40%<wbr>2FK64aE%3D&reserved=0</a><br>
><br>
><br>
><br>
> --<br>
> Bruno Cardoso Lopes<br>
> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.brunocardoso.cc&data=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946&sdata=O01DYn4W3JN54%2B6wwAgCLAkq63PUtUBy4mQ9RMN833s%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.brunocardoso.<wbr>cc&data=02%7C01%7Ceriksc%<wbr>40microsoft.com%<wbr>7Cba4835eb4a1b438793d508d4b448<wbr>1355%<wbr>7C72f988bf86f141af91ab2d7cd011<wbr>db47%7C1%7C0%<wbr>7C636331669036098946&sdata=<wbr>O01DYn4W3JN54%<wbr>2B6wwAgCLAkq63PUtUBy4mQ9RMN833<wbr>s%3D&reserved=0</a><br>
<br>
<br>
<br>
--<br>
Bruno Cardoso Lopes<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.brunocardoso.cc&data=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946&sdata=O01DYn4W3JN54%2B6wwAgCLAkq63PUtUBy4mQ9RMN833s%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.brunocardoso.<wbr>cc&data=02%7C01%7Ceriksc%<wbr>40microsoft.com%<wbr>7Cba4835eb4a1b438793d508d4b448<wbr>1355%<wbr>7C72f988bf86f141af91ab2d7cd011<wbr>db47%7C1%7C0%<wbr>7C636331669036098946&sdata=<wbr>O01DYn4W3JN54%<wbr>2B6wwAgCLAkq63PUtUBy4mQ9RMN833<wbr>s%3D&reserved=0</a><br>
</div></div></blockquote></div><br></div>