[llvm] r297192 - Fix C2712 build error on Windows
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 7 12:09:46 PST 2017
Author: kzhuravl
Date: Tue Mar 7 14:09:46 2017
New Revision: 297192
URL: http://llvm.org/viewvc/llvm-project?rev=297192&view=rev
Log:
Fix C2712 build error on Windows
Move the __try/__except block outside of the set_thread_name function to avoid a conflict with object unwinding due to the use of the llvm::Storage.
Differential Revision: https://reviews.llvm.org/D30707
Modified:
llvm/trunk/lib/Support/Windows/Threading.inc
Modified: llvm/trunk/lib/Support/Windows/Threading.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Threading.inc?rev=297192&r1=297191&r2=297192&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Threading.inc (original)
+++ llvm/trunk/lib/Support/Windows/Threading.inc Tue Mar 7 14:09:46 2017
@@ -61,11 +61,8 @@ uint64_t llvm::get_threadid() {
uint32_t llvm::get_max_thread_name_length() { return 0; }
-void llvm::set_thread_name(const Twine &Name) {
#if defined(_MSC_VER)
- // Make sure the input is null terminated.
- SmallString<64> Storage;
- StringRef NameStr = Name.toNullTerminatedStringRef(Storage);
+static void SetThreadName(DWORD Id, LPCSTR Name) {
constexpr DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push, 8)
@@ -79,8 +76,8 @@ void llvm::set_thread_name(const Twine &
THREADNAME_INFO info;
info.dwType = 0x1000;
- info.szName = NameStr.data();
- info.dwThreadId = ::GetCurrentThreadId();
+ info.szName = Name;
+ info.dwThreadId = Id;
info.dwFlags = 0;
__try {
@@ -89,6 +86,15 @@ void llvm::set_thread_name(const Twine &
}
__except (EXCEPTION_EXECUTE_HANDLER) {
}
+}
+#endif
+
+void llvm::set_thread_name(const Twine &Name) {
+#if defined(_MSC_VER)
+ // Make sure the input is null terminated.
+ SmallString<64> Storage;
+ StringRef NameStr = Name.toNullTerminatedStringRef(Storage);
+ SetThreadName(::GetCurrentThreadId(), NameStr.data());
#endif
}
More information about the llvm-commits
mailing list