From 55907d1274ce715b92d584e305e0708e333a33c0 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 29 Aug 2012 22:57:00 +0000 Subject: Replace the BUILTIN_EXPECT macro with a less horrible LLVM_LIKELY/LLVM_UNLIKELY interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162873 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/llvm/Support/Compiler.h') diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index ea0a4da..28e4cc6 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -106,9 +106,11 @@ #endif #if (__GNUC__ >= 4) -#define BUILTIN_EXPECT(EXPR, VALUE) __builtin_expect((EXPR), (VALUE)) +#define LLVM_LIKELY(EXPR) __builtin_expect((EXPR), true) +#define LLVM_UNLIKELY(EXPR) __builtin_expect((EXPR), false) #else -#define BUILTIN_EXPECT(EXPR, VALUE) (EXPR) +#define LLVM_LIKELY(EXPR) (EXPR) +#define LLVM_UNLIKELY(EXPR) (EXPR) #endif -- cgit v1.1 From 4d69a8c8b2133e441503ac9583c4a6056f52e0f3 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 29 Aug 2012 23:28:45 +0000 Subject: Explicitly cast an expression to bool before handing it off to __builtin_expect. Avoids surprises when someone uses LLVM_(UN)LIKELY with an integer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162877 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/llvm/Support/Compiler.h') diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 28e4cc6..4f5b8f8 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -106,8 +106,8 @@ #endif #if (__GNUC__ >= 4) -#define LLVM_LIKELY(EXPR) __builtin_expect((EXPR), true) -#define LLVM_UNLIKELY(EXPR) __builtin_expect((EXPR), false) +#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) +#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) #else #define LLVM_LIKELY(EXPR) (EXPR) #define LLVM_UNLIKELY(EXPR) (EXPR) -- cgit v1.1 From e20cf3d14997c3511e264748c59687a801caa6ed Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 4 Sep 2012 17:42:53 +0000 Subject: Make sure macros in the include subdirectory are not used without being defined. Rationale: For each preprocessor macro, either the definedness is what's meaningful, or the value is what's meaningful, or both. If definedness is meaningful, we should use #ifdef. If the value is meaningful, we should use and #ifdef interchangeably for the same macro, seems ugly to me, even if undefined macros are zero if used. This also has the benefit that including an LLVM header doesn't prevent you from compiling with -Wundef -Werror. Patch by John Garvin! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163148 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/llvm/Support/Compiler.h') diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 4f5b8f8..1136ff7 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -24,7 +24,7 @@ /// does not imply the existence of any other C++ library features. #if (__has_feature(cxx_rvalue_references) \ || defined(__GXX_EXPERIMENTAL_CXX0X__) \ - || _MSC_VER >= 1600) + || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define LLVM_USE_RVALUE_REFERENCES 1 #else #define LLVM_USE_RVALUE_REFERENCES 0 -- cgit v1.1