[PATCH] D18002: Add an LLVM_BUILTIN_DEBUGTRAP macro.

Mark Lacey via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 21:20:07 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL263095: Add an LLVM_BUILTIN_DEBUGTRAP macro. (authored by rudkx).

Changed prior to commit:
  http://reviews.llvm.org/D18002?vs=50164&id=50235#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18002

Files:
  llvm/trunk/include/llvm/Support/Compiler.h

Index: llvm/trunk/include/llvm/Support/Compiler.h
===================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h
+++ llvm/trunk/include/llvm/Support/Compiler.h
@@ -274,6 +274,23 @@
 # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
 #endif
 
+/// LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to
+/// an expression which causes the program to break while running
+/// under a debugger.
+#if __has_builtin(__builtin_debugtrap)
+# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
+#elif defined(_MSC_VER)
+// The __debugbreak intrinsic is supported by MSVC and breaks while
+// running under the debugger, and also supports invoking a debugger
+// when the OS is configured appropriately.
+# define LLVM_BUILTIN_DEBUGTRAP __debugbreak()
+#else
+// Just continue execution when built with compilers that have no
+// support. This is a debugging aid and not intended to force the
+// program to abort if encountered.
+# define LLVM_BUILTIN_DEBUGTRAP
+#endif
+
 /// \macro LLVM_ASSUME_ALIGNED
 /// \brief Returns a pointer with an assumed alignment.
 #if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18002.50235.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/0d5c643c/attachment.bin>


More information about the llvm-commits mailing list