Skip to content

Commit 112aafc

Browse files
committed
Revert "Add a cmake flag to turn llvm_unreachable() into builtin_trap() when assertions are disabled"
This reverts commit 6316129. This was implemented with inverted logic.
1 parent ae3e3c6 commit 112aafc

File tree

4 files changed

+3
-22
lines changed

4 files changed

+3
-22
lines changed

llvm/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
465465
option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
466466

467467
option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF)
468-
option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON)
469468

470469
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
471470
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)

llvm/docs/CMake.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ enabled sub-projects. Nearly all of these variable names begin with
300300
enabled or not. A version of LLVM built with ABI breaking checks
301301
is not ABI compatible with a version built without it.
302302

303-
**LLVM_UNREACHABLE_OPTIMIZE**:BOOL
304-
This flag controls the behavior of `llvm_unreachable()` in release build
305-
(when assertions are disabled in general). When ON (default) then
306-
`llvm_unreachable()` is considered "undefined behavior" and optimized as
307-
such. When OFF it is instead replaced with a guaranteed "trap".
308-
309303
**LLVM_APPEND_VC_REV**:BOOL
310304
Embed version control revision info (Git revision id).
311305
The version info is provided by the ``LLVM_REVISION`` macro in

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,4 @@
112112
/* Define if building LLVM with LLVM_FORCE_USE_OLD_TOOLCHAIN_LIBS */
113113
#cmakedefine LLVM_FORCE_USE_OLD_TOOLCHAIN ${LLVM_FORCE_USE_OLD_TOOLCHAIN}
114114

115-
/* Define if llvm_unreachable should be optimized with undefined behavior
116-
* in non assert builds */
117-
#cmakedefine01 LLVM_UNREACHABLE_OPTIMIZE
118-
119115
#endif

llvm/include/llvm/Support/ErrorHandling.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,15 @@ llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr,
124124

125125
/// Marks that the current location is not supposed to be reachable.
126126
/// In !NDEBUG builds, prints the message and location info to stderr.
127-
/// In NDEBUG builds, the behavior is controlled by the CMake flag
128-
/// -DLLVM_UNREACHABLE_OPTIMIZE
129-
/// * When "ON" (default) llvm_unreachable() becomes an optimizer hint
130-
/// that the current location is not supposed to be reachable: the hint
131-
/// turns such code path into undefined behavior. On compilers that don't
132-
/// support such hints, prints a reduced message instead and aborts the
133-
/// program.
134-
/// * When "OFF", a builtin_trap is emitted instead of an
135-
// optimizer hint or printing a reduced message.
127+
/// In NDEBUG builds, becomes an optimizer hint that the current location
128+
/// is not supposed to be reachable. On compilers that don't support
129+
/// such hints, prints a reduced message instead and aborts the program.
136130
///
137131
/// Use this instead of assert(0). It conveys intent more clearly and
138132
/// allows compilers to omit some unnecessary code.
139133
#ifndef NDEBUG
140134
#define llvm_unreachable(msg) \
141135
::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
142-
#elif LLVM_UNREACHABLE_OPTIMIZE
143-
#define llvm_unreachable(msg) LLVM_BUILTIN_TRAP
144136
#elif defined(LLVM_BUILTIN_UNREACHABLE)
145137
#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
146138
#else

0 commit comments

Comments
 (0)