[llvm] 892c104 - Compiler: Remove empty fallback definition for LLVM_BUILTIN_UNREACHABLE

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 11:52:51 PDT 2022


Author: Duncan P. N. Exon Smith
Date: 2022-03-21T11:52:24-07:00
New Revision: 892c104fb71b86dc6399e36a82ae920e00ccae17

URL: https://github.com/llvm/llvm-project/commit/892c104fb71b86dc6399e36a82ae920e00ccae17
DIFF: https://github.com/llvm/llvm-project/commit/892c104fb71b86dc6399e36a82ae920e00ccae17.diff

LOG: Compiler: Remove empty fallback definition for LLVM_BUILTIN_UNREACHABLE

`llvm_unreachable()` and `LLVM_ASSUME_ALIGNED` use
`defined(LLVM_BUILTIN_UNREACHABLE)` to check whether it has a
definition. Remove the fallback added in 26827337dff26ba3 (as a drive-by
when updating the GCC logic) and add a comment to prevent future
mistakes.

Differential Revision: https://reviews.llvm.org/D122167

Added: 
    

Modified: 
    llvm/include/llvm/Support/Compiler.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index e97da6bd4ef05..262eca00014bf 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -321,12 +321,14 @@
 /// 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.  Otherwise is not defined.
+///
+/// '#else' is intentionally left out so that other macro logic (e.g.,
+/// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether
+/// LLVM_BUILTIN_UNREACHABLE has a definition.
 #if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
 # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
 #elif defined(_MSC_VER)
 # define LLVM_BUILTIN_UNREACHABLE __assume(false)
-#else
-# define LLVM_BUILTIN_UNREACHABLE
 #endif
 
 /// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression


        


More information about the llvm-commits mailing list