[llvm-commits] [llvm] r162877 - /llvm/trunk/include/llvm/Support/Compiler.h
Benjamin Kramer
benny.kra at googlemail.com
Wed Aug 29 16:28:45 PDT 2012
Author: d0k
Date: Wed Aug 29 18:28:45 2012
New Revision: 162877
URL: http://llvm.org/viewvc/llvm-project?rev=162877&view=rev
Log:
Explicitly cast an expression to bool before handing it off to __builtin_expect.
Avoids surprises when someone uses LLVM_(UN)LIKELY with an integer.
Modified:
llvm/trunk/include/llvm/Support/Compiler.h
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=162877&r1=162876&r2=162877&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Wed Aug 29 18:28:45 2012
@@ -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)
More information about the llvm-commits
mailing list