Closed Bug 1022049 Opened 10 years ago Closed 10 years ago

Disable bitscan intrinsics on clang-cl because it doesn't support #pragma intrinsic

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: ehsan.akhgari, Assigned: jrmuizel)

References

Details

Attachments

(1 file, 2 obsolete files)

      No description provided.
Assignee: nobody → ehsan
Blocks: winclang
Attachment #8436194 - Flags: review?(nfroyd)
Can we just #include <intrinsic.h> instead? We'll need to do that for the atomic intrinsics anyways.
(In reply to Jeff Muizelaar [:jrmuizel] from comment #2)
> Can we just #include <intrinsic.h> instead? We'll need to do that for the
> atomic intrinsics anyways.

Will that fix the error?  I wrote this patch according to our local workaround.
Flags: needinfo?(jmuizelaar)
Comment on attachment 8436194 [details] [diff] [review]
Disable bitscan intrinsics on clang-cl because it doesn't support #pragma intrinsic

Jeff is right!
Attachment #8436194 - Attachment is obsolete: true
Attachment #8436194 - Flags: review?(nfroyd)
Attachment #8436564 - Flags: review?(nfroyd)
Comment on attachment 8436564 [details] [diff] [review]
#include intrin.h directly instead of defining the intrinsics manually; r=froydnj

Review of attachment 8436564 [details] [diff] [review]:
-----------------------------------------------------------------

I don't understand how Jeff is right here; we manually prototype the Atomics.h stuff already?

::: mfbt/MathAlgorithms.h
@@ +146,5 @@
>  } // namespace mozilla
>  
>  #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
>  #  define MOZ_BITSCAN_WINDOWS
> +#  include <intrin.h>

Can you provide some sort of idea of how many headers this pulls in?  For instance, we're not dragging in windows.h just for this, are we?

For the Atomics.h stuff, we just copied in our own prototypes rather than #include'ing what we need, in an effort to keep these headers light.  I suppose the same motivations were present here.
Attachment #8436564 - Flags: review?(nfroyd)
Comment on attachment 8436564 [details] [diff] [review]
#include intrin.h directly instead of defining the intrinsics manually; r=froydnj

This pulls in only 25 headers, some of which are already popular ones, such as malloc.h, stddef.h (and the list doesn't include windows.h.

I find it really surprising to micro-optimize not pulling in this header and provide our own definitions.  Also note that this code was added in bug 356856, and I doubt there was a concern of the size of the headers there at all.
Attachment #8436564 - Flags: review?(nfroyd)
Comment on attachment 8436564 [details] [diff] [review]
#include intrin.h directly instead of defining the intrinsics manually; r=froydnj

Review of attachment 8436564 [details] [diff] [review]:
-----------------------------------------------------------------

Well, clearly in 2006, people were adding their own prototypes for whatever reasons, so...

Unless I'm missing something, intrin.h doesn't #pragma intrinsic anything, so we'll get out-of-line function calls for what were previously inlined code...right?
Attachment #8436564 - Flags: review?(nfroyd)
Comment on attachment 8436564 [details] [diff] [review]
#include intrin.h directly instead of defining the intrinsics manually; r=froydnj

Review of attachment 8436564 [details] [diff] [review]:
-----------------------------------------------------------------

::: mfbt/MathAlgorithms.h
@@ +146,5 @@
>  } // namespace mozilla
>  
>  #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
>  #  define MOZ_BITSCAN_WINDOWS
> +#  include <intrin.h>

If we need to we could only #include <intrin.h> with clang and leave our own definitions for msvc.

@@ -156,5 @@
> -#  if defined(_M_AMD64) || defined(_M_X64)
> -#    define MOZ_BITSCAN_WINDOWS64
> -    unsigned char _BitScanForward64(unsigned long* index, unsigned __int64 mask);
> -    unsigned char _BitScanReverse64(unsigned long* index, unsigned __int64 mask);
> -#   pragma intrinsic(_BitScanForward64, _BitScanReverse64)

I believe the pragma intrinsic(...) should stay. clang ignores it.
Hmm, so I reverted the patch and clang-cl seems to build MathAlgorithms.h quite happily without it.  Not sure what problem we were hitting before but it doesn't seem to exist any more.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(jmuizelaar)
Resolution: --- → INVALID
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Assignee: ehsan → jmuizelaar
For those following along at home, Jeff told me that the error we were getting was during linking, which explains why I did not see it in comment 10.
This just removes the manual definitions and includes <intrin.h>. The pragmas are left. This builds fine on windows https://tbpl.mozilla.org/?tree=Try&rev=af950949b678 and is more correct than manually defining these functions ourselves.
Attachment #8436564 - Attachment is obsolete: true
Attachment #8437441 - Flags: review?(nfroyd)
Comment on attachment 8437441 [details] [diff] [review]
#include intrin.h directly instead of defining the intrinsics manually; r=froydnj

Review of attachment 8437441 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the change below.

::: mfbt/MathAlgorithms.h
@@ +152,1 @@
>    extern "C" {

Please remove the extern "C" wrapper; it doesn't seem to be needed for the pragmas (cf. similar code in Atomics.h).
Attachment #8437441 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/e19324807568
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: