[PATCH] D122170: Adjust `llvm_unreachable` macro to account for platforms that don't define LLVM_BUILTIN_UNREACHABLE
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 21 13:50:28 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG734b8eadd7d3: Adjust `llvm_unreachable` macro to account for platforms that don't defineā¦ (authored by mehdi_amini).
Changed prior to commit:
https://reviews.llvm.org/D122170?vs=417061&id=417085#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122170/new/
https://reviews.llvm.org/D122170
Files:
llvm/include/llvm/Support/ErrorHandling.h
Index: llvm/include/llvm/Support/ErrorHandling.h
===================================================================
--- llvm/include/llvm/Support/ErrorHandling.h
+++ llvm/include/llvm/Support/ErrorHandling.h
@@ -124,7 +124,9 @@
/// 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, the behavior is controlled by the CMake flag
+/// In NDEBUG builds, if the platform does not support a builtin unreachable
+/// then we call an internal LLVM runtime function. Otherwise the behavior is
+/// controlled by the CMake flag
/// -DLLVM_UNREACHABLE_OPTIMIZE
/// * When "ON" (default) llvm_unreachable() becomes an optimizer hint
/// that the current location is not supposed to be reachable: the hint
@@ -134,17 +136,18 @@
/// * When "OFF", a builtin_trap is emitted instead of an
// optimizer hint or printing a reduced message.
///
-/// Use this instead of assert(0). It conveys intent more clearly and
-/// allows compilers to omit some unnecessary code.
+/// Use this instead of assert(0). It conveys intent more clearly, suppresses
+/// diagnostics for unreachable code paths, and allows compilers to omit
+/// unnecessary code.
#ifndef NDEBUG
#define llvm_unreachable(msg) \
::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
-#elif !LLVM_UNREACHABLE_OPTIMIZE
-#define llvm_unreachable(msg) LLVM_BUILTIN_TRAP
-#elif defined(LLVM_BUILTIN_UNREACHABLE)
+#elif !defined(LLVM_BUILTIN_UNREACHABLE)
+#define llvm_unreachable(msg) ::llvm::llvm_unreachable_internal()
+#elif LLVM_UNREACHABLE_OPTIMIZE
#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
#else
-#define llvm_unreachable(msg) ::llvm::llvm_unreachable_internal()
+#define llvm_unreachable(msg) LLVM_BUILTIN_TRAP, LLVM_BUILTIN_UNREACHABLE
#endif
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122170.417085.patch
Type: text/x-patch
Size: 1854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220321/e848c488/attachment.bin>
More information about the llvm-commits
mailing list