[llvm-commits] [llvm] r127608 - in /llvm/trunk/include/llvm/Support: Compiler.h ErrorHandling.h
John McCall
rjmccall at apple.com
Mon Mar 14 13:01:21 PDT 2011
Author: rjmccall
Date: Mon Mar 14 15:01:21 2011
New Revision: 127608
URL: http://llvm.org/viewvc/llvm-project?rev=127608&view=rev
Log:
Make llvm_unreachable evaluate to __builtin_unreachable() in -Asserts
builds, which was the apparent consensus of PR8973 and llvmdev.
Modified:
llvm/trunk/include/llvm/Support/Compiler.h
llvm/trunk/include/llvm/Support/ErrorHandling.h
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=127608&r1=127607&r2=127608&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Mon Mar 14 15:01:21 2011
@@ -126,4 +126,19 @@
decl
#endif
+// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
+// to an expression which states that it is undefined behavior for the
+// compiler to reach this point.
+#if defined(__clang__) || (__GNUC__ > 4) \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
+#else
+#ifdef __cplusplus
+extern "C" LLVM_ATTRIBUTE_NORETURN void abort();
+#else
+extern LLVM_ATTRIBUTE_NORETURN void abort();
+#endif
+# define LLVM_BUILTIN_UNREACHABLE abort()
+#endif
+
#endif
Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=127608&r1=127607&r2=127608&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorHandling.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorHandling.h Mon Mar 14 15:01:21 2011
@@ -97,7 +97,7 @@
#define llvm_unreachable(msg) \
::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
#else
-#define llvm_unreachable(msg) ::llvm::llvm_unreachable_internal()
+#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
#endif
#endif
More information about the llvm-commits
mailing list