[llvm-commits] [llvm] r127629 - in /llvm/trunk/include/llvm/Support: Compiler.h ErrorHandling.h
John McCall
rjmccall at apple.com
Mon Mar 14 15:41:50 PDT 2011
Author: rjmccall
Date: Mon Mar 14 17:41:50 2011
New Revision: 127629
URL: http://llvm.org/viewvc/llvm-project?rev=127629&view=rev
Log:
Version N of the llvm_unreachable patch: VC++ doesn't recognize that abort()
doesn't return, so just go back to using the old runtime function instead
of trying to use abort() when __builtin_unreachable (or an equivalent) isn't
supported.
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=127629&r1=127628&r2=127629&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Mon Mar 14 17:41:50 2011
@@ -128,12 +128,10 @@
// 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.
+// compiler to reach this point. Otherwise is not defined.
#if defined(__clang__) || (__GNUC__ > 4) \
|| (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
-#else
-# 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=127629&r1=127628&r2=127629&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorHandling.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorHandling.h Mon Mar 14 17:41:50 2011
@@ -86,18 +86,21 @@
unsigned line=0);
}
-/// Prints the message and location info to stderr in !NDEBUG builds.
-/// This is intended to be used for "impossible" situations that imply
-/// a bug in the compiler.
+/// Marks that the current location is not supposed to be reachable.
+/// In !NDEBUG builds, prints the message and location info to stderr.
+/// In NDEBUG builds, becomes an optimizer hint that the current location
+/// is not supposed to be reachable. On compilers that don't support
+/// such hints, prints a reduced message instead.
///
-/// In NDEBUG mode it only prints "UNREACHABLE executed".
-/// Use this instead of assert(0), so that the compiler knows this path
-/// is not reachable even for NDEBUG builds.
+/// Use this instead of assert(0). It conveys intent more clearly and
+/// allows compilers to omit some unnecessary code.
#ifndef NDEBUG
#define llvm_unreachable(msg) \
::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
-#else
+#elif defined(LLVM_BUILTIN_UNREACHABLE)
#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
+#else
+#define llvm_unreachable(msg) ::llvm::llvm_unreachable_internal()
#endif
#endif
More information about the llvm-commits
mailing list