[llvm] r335406 - Avoid including intrin.h from MathExtras.h

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 18:19:50 PDT 2018


Author: rnk
Date: Fri Jun 22 18:19:49 2018
New Revision: 335406

URL: http://llvm.org/viewvc/llvm-project?rev=335406&view=rev
Log:
Avoid including intrin.h from MathExtras.h

This is repeatably worth 0.3s compile time on MathExtras.cpp. This is a
very popular header, and it basically pulls all Intel intrinsics into
every LLVM TU. Let's not do that.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=335406&r1=335405&r2=335406&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Fri Jun 22 18:19:49 2018
@@ -23,14 +23,20 @@
 #include <limits>
 #include <type_traits>
 
-#ifdef _MSC_VER
-#include <intrin.h>
-#endif
-
 #ifdef __ANDROID_NDK__
 #include <android/api-level.h>
 #endif
 
+#ifdef _MSC_VER
+// Declare these intrinsics manually rather including intrin.h. It's very
+// expensive, and MathExtras.h is popular.
+// #include <intrin.h>
+extern "C" {
+unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+}
+#endif
+
 namespace llvm {
 /// The behavior an operation has on an input of 0.
 enum ZeroBehavior {




More information about the llvm-commits mailing list