[llvm] Windows: use EcoQoS for ThreadPriority::Background (PR #148797)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 06:59:00 PDT 2025
================
@@ -107,6 +107,35 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
}
SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
+
+ // SetThreadInformation is only available on Windows 8 and later. Since we still
+ // support compilation on Windows 7, we load the function dynamically.
+ typedef BOOL(WINAPI * SetThreadInformation_t)(
+ HANDLE hThread, THREAD_INFORMATION_CLASS ThreadInformationClass,
+ _In_reads_bytes_(ThreadInformationSize) PVOID ThreadInformation,
+ ULONG ThreadInformationSize);
+ static const auto pfnSetThreadInformation =
+ (SetThreadInformation_t)GetProcAddress(
+ GetModuleHandle(TEXT("kernel32.dll")), "SetThreadInformation");
+
+ if (pfnSetThreadInformation) {
+ auto setThreadInformation = [](ULONG ControlMaskAndStateMask) {
+ THREAD_POWER_THROTTLING_STATE state{};
+ state.Version = THREAD_POWER_THROTTLING_CURRENT_VERSION;
+ state.ControlMask = ControlMask;
----------------
aganea wrote:
You need to change `ControlMask` for `ControlMaskAndStateMask` and same below, `StateMask` for `ControlMaskAndStateMask`.
https://github.com/llvm/llvm-project/pull/148797
More information about the llvm-commits
mailing list