[llvm] r228691 - Re-committing r228628 with a fix for 64-bit builds.

Aaron Ballman aaron at aaronballman.com
Tue Feb 10 06:28:11 PST 2015


Author: aaronballman
Date: Tue Feb 10 08:28:11 2015
New Revision: 228691

URL: http://llvm.org/viewvc/llvm-project?rev=228691&view=rev
Log:
Re-committing r228628 with a fix for 64-bit builds.

On Windows, we now use RaiseException to generate the kind of trap we require (one which calls our vectored exception handler), and fall back to using a volatile write to simulate a trap elsewhere.

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

Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=228691&r1=228690&r2=228691&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Tue Feb 10 08:28:11 2015
@@ -287,6 +287,19 @@
 /// which causes the program to exit abnormally.
 #if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0)
 # define LLVM_BUILTIN_TRAP __builtin_trap()
+#elif defined(LLVM_ON_WIN32)
+#if defined(_WIN64)
+extern "C" __declspec(dllimport) void __stdcall RaiseException(
+    unsigned long, unsigned long, unsigned long, const unsigned long long *);
+#else
+extern "C" __declspec(dllimport) void __stdcall RaiseException(
+    unsigned long, unsigned long, unsigned long, const unsigned long *);
+#endif
+# define LLVM_BUILTIN_TRAP                                                     \
+  do {                                                                         \
+    ::RaiseException(0xDEADD0D0, 0x1 /*EXCEPTION_NONCONTINUABLE*/, 0, nullptr);\
+    __assume(false);                                                           \
+  } while (0)
 #else
 # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
 #endif





More information about the llvm-commits mailing list