From 30d00ef817b549e888a9dc2a665dc005af958c1d Mon Sep 17 00:00:00 2001 From: Wenju He Date: Wed, 29 Oct 2025 08:17:41 +0100 Subject: [PATCH] Remove compileMutex to enable parallel compilation on Windows The issue observed in 76bc7f93d591 seems fixed on llvm-14 branch based on new testing of a multi-threaded workload on Ice Lake server and Alder Lake desktop. The same workload still fails on llvm-9 branch on Alder Lake. --- common_clang.cpp | 11 ----------- options_compile.cpp | 6 ------ 2 files changed, 17 deletions(-) diff --git a/common_clang.cpp b/common_clang.cpp index 4b2579cc..43a41c1b 100644 --- a/common_clang.cpp +++ b/common_clang.cpp @@ -85,8 +85,6 @@ static volatile bool lazyCCInit = true; // the flag must be 'volatile' to prevent caching in a CPU register static llvm::sys::Mutex lazyCCInitMutex; -llvm::ManagedStatic> compileMutex; - void CommonClangTerminate() { llvm::llvm_shutdown(); } // This function mustn't be invoked from a static object constructor, @@ -212,9 +210,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, CommonClangInitialize(); try { -#ifdef _WIN32 - llvm::sys::SmartScopedLock compileGuard{*compileMutex}; -#endif std::unique_ptr pResult(new OCLFEBinaryResult()); // Create the clang compiler @@ -226,9 +221,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, // Prepare error log llvm::raw_string_ostream err_ostream(pResult->getLogRef()); { -#ifndef _WIN32 - llvm::sys::SmartScopedLock compileGuard{*compileMutex}; -#endif // Parse options optionsParser.processOptions(pszOptions, pszOptionsEx); @@ -347,9 +339,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, err_ostream.flush(); } { -#ifndef _WIN32 - llvm::sys::SmartScopedLock compileGuard{*compileMutex}; -#endif if (pBinaryResult) { *pBinaryResult = pResult.release(); } diff --git a/options_compile.cpp b/options_compile.cpp index 25cb1d66..5b922569 100644 --- a/options_compile.cpp +++ b/options_compile.cpp @@ -39,8 +39,6 @@ Copyright (c) Intel Corporation (2009-2017). using namespace llvm::opt; -extern llvm::ManagedStatic> compileMutex; - static const OptTable::Info ClangOptionsInfoTable[] = { #define PREFIX(NAME, VALUE) #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ @@ -442,10 +440,6 @@ std::string CompileOptionsParser::getEffectiveOptionsAsString() const { extern "C" CC_DLL_EXPORT bool CheckCompileOptions(const char *pszOptions, char *pszUnknownOptions, size_t uiUnknownOptionsSize) { - // LLVM doesn't guarantee thread safety, - // therefore we serialize execution of LLVM code. - llvm::sys::SmartScopedLock compileOptionsGuard{*compileMutex}; - try { CompileOptionsParser optionsParser("200"); return optionsParser.checkOptions(pszOptions, pszUnknownOptions,