Skip to content

Commit 18ec882

Browse files
authored
Remove compileMutex to enable parallel compilation on Windows (#583)
The issue observed in 76bc7f9 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.
1 parent f7a873d commit 18ec882

File tree

2 files changed

+0
-17
lines changed

2 files changed

+0
-17
lines changed

common_clang.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ static volatile bool lazyCCInit =
8585
true; // the flag must be 'volatile' to prevent caching in a CPU register
8686
static llvm::sys::Mutex lazyCCInitMutex;
8787

88-
llvm::ManagedStatic<llvm::sys::SmartMutex<true>> compileMutex;
89-
9088
void CommonClangTerminate() { llvm::llvm_shutdown(); }
9189

9290
// This function mustn't be invoked from a static object constructor,
@@ -212,9 +210,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
212210
CommonClangInitialize();
213211

214212
try {
215-
#ifdef _WIN32
216-
llvm::sys::SmartScopedLock<true> compileGuard{*compileMutex};
217-
#endif
218213
std::unique_ptr<OCLFEBinaryResult> pResult(new OCLFEBinaryResult());
219214

220215
// Create the clang compiler
@@ -226,9 +221,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
226221
// Prepare error log
227222
llvm::raw_string_ostream err_ostream(pResult->getLogRef());
228223
{
229-
#ifndef _WIN32
230-
llvm::sys::SmartScopedLock<true> compileGuard{*compileMutex};
231-
#endif
232224
// Parse options
233225
optionsParser.processOptions(pszOptions, pszOptionsEx);
234226

@@ -347,9 +339,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
347339
err_ostream.flush();
348340
}
349341
{
350-
#ifndef _WIN32
351-
llvm::sys::SmartScopedLock<true> compileGuard{*compileMutex};
352-
#endif
353342
if (pBinaryResult) {
354343
*pBinaryResult = pResult.release();
355344
}

options_compile.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ Copyright (c) Intel Corporation (2009-2017).
3939

4040
using namespace llvm::opt;
4141

42-
extern llvm::ManagedStatic<llvm::sys::SmartMutex<true>> compileMutex;
43-
4442
static const OptTable::Info ClangOptionsInfoTable[] = {
4543
#define PREFIX(NAME, VALUE)
4644
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
@@ -442,10 +440,6 @@ std::string CompileOptionsParser::getEffectiveOptionsAsString() const {
442440
extern "C" CC_DLL_EXPORT bool CheckCompileOptions(const char *pszOptions,
443441
char *pszUnknownOptions,
444442
size_t uiUnknownOptionsSize) {
445-
// LLVM doesn't guarantee thread safety,
446-
// therefore we serialize execution of LLVM code.
447-
llvm::sys::SmartScopedLock<true> compileOptionsGuard{*compileMutex};
448-
449443
try {
450444
CompileOptionsParser optionsParser("200");
451445
return optionsParser.checkOptions(pszOptions, pszUnknownOptions,

0 commit comments

Comments
 (0)