[llvm] 1c60b7d - [Support] [Windows] Conditionally compile the SetThreadInformation calls (#151388)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 11:54:12 PDT 2025


Author: Martin Storsjö
Date: 2025-07-31T21:54:09+03:00
New Revision: 1c60b7da4f7af388b12f4f9b1d46bab0b65c5155

URL: https://github.com/llvm/llvm-project/commit/1c60b7da4f7af388b12f4f9b1d46bab0b65c5155
DIFF: https://github.com/llvm/llvm-project/commit/1c60b7da4f7af388b12f4f9b1d46bab0b65c5155.diff

LOG: [Support] [Windows] Conditionally compile the SetThreadInformation calls (#151388)

The declarations for this API are missing in older mingw-w64 headers
(versions before v12). This API is also hidden if building with MS
WinSDK if targeting versions before Windows 10.

Check whether THREAD_POWER_THROTTLING_CURRENT_VERSION is defined before
using this API; this constant is a #define in both WinSDK and mingw-w64.

Added: 
    

Modified: 
    llvm/lib/Support/Windows/Threading.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 8dd7c88fad34a..b11f216adeba4 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -136,6 +136,7 @@ HMODULE loadSystemModuleSecure(LPCWSTR lpModuleName) {
 } // namespace llvm::sys::windows
 
 SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
+#ifdef THREAD_POWER_THROTTLING_CURRENT_VERSION
   HMODULE kernelM = llvm::sys::windows::loadSystemModuleSecure(L"kernel32.dll");
   if (kernelM) {
     // SetThreadInformation is only available on Windows 8 and later. Since we
@@ -166,6 +167,7 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
                                : 0);
     }
   }
+#endif
 
   // https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setthreadpriority
   // Begin background processing mode. The system lowers the resource scheduling


        


More information about the llvm-commits mailing list