From c5b2a1fba4b35c998e849c975f6c4d43457f5cba Mon Sep 17 00:00:00 2001 From: Douglas Whittingham Date: Wed, 16 Sep 2026 11:38:37 -1000 Subject: [PATCH] Use a portable popcount so MSVC can build the LLVM backend __builtin_popcountll is a GCC/Clang builtin with no MSVC equivalent, so an MSVC build of the LLVM backend fails outright: abi_policy.cpp(15): error C3861: '__builtin_popcountll': identifier not found CI does not catch this because no job builds that combination. The windows-latest MSVC job configures without DOLRECOMP_ENABLE_LLVM, so this file is never compiled; the "LLVM backend (windows-latest)" job does enable it but builds under MSYS2/UCRT64 with mingw GCC, which has the builtin. MSVC plus the LLVM backend is the configuration a local Windows toolchain actually uses. std::bitset<64>::count() is C++17, needs no feature test, and lowers to popcnt on every compiler that has the instruction. This was the only __builtin_ in src/. --- src/backend/llvm/abi_policy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/llvm/abi_policy.cpp b/src/backend/llvm/abi_policy.cpp index e6651d5..0e8131a 100644 --- a/src/backend/llvm/abi_policy.cpp +++ b/src/backend/llvm/abi_policy.cpp @@ -1,6 +1,7 @@ #include "backend/llvm/llvm_backend.h" #include +#include #include #include #include @@ -12,7 +13,7 @@ u32 stateCount(const u64 *first, const u64 *second = nullptr) { u32 count = 0; for (u32 word = 0; word < DOLIR_STATE_MASK_WORDS; word++) count += static_cast( - __builtin_popcountll(first[word] | (second ? second[word] : 0u))); + std::bitset<64>(first[word] | (second ? second[word] : 0u)).count()); return count; }