r210601 - Clang changes to support LLVM removal of runtime multithreading

Zachary Turner zturner at google.com
Tue Jun 10 16:02:10 PDT 2014


Author: zturner
Date: Tue Jun 10 18:02:10 2014
New Revision: 210601

URL: http://llvm.org/viewvc/llvm-project?rev=210601&view=rev
Log:
Clang changes to support LLVM removal of runtime multithreading
support (llvm revision r210600).

Reviewers: rnk

Differential Revision: http://reviews.llvm.org/D4077

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=210601&r1=210600&r2=210601&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jun 10 18:02:10 2014
@@ -2556,8 +2556,8 @@ buildPieces(unsigned NameFlags, bool IsM
 // Misc. API hooks.
 //===----------------------------------------------------------------------===//               
 
-static llvm::sys::Mutex EnableMultithreadingMutex;
-static bool EnabledMultithreading;
+static llvm::sys::Mutex LoggingMutex;
+static std::once_flag InstalledErrorHandlerFlag;
 
 static void fatal_error_handler(void *user_data, const std::string& reason,
                                 bool gen_crash_diag) {
@@ -2575,15 +2575,8 @@ CXIndex clang_createIndex(int excludeDec
   if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY"))
     llvm::CrashRecoveryContext::Enable();
 
-  // Enable support for multithreading in LLVM.
-  {
-    llvm::sys::ScopedLock L(EnableMultithreadingMutex);
-    if (!EnabledMultithreading) {
-      llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
-      llvm::llvm_start_multithreaded();
-      EnabledMultithreading = true;
-    }
-  }
+  std::call_once(InstalledErrorHandlerFlag,
+      []() {llvm::install_fatal_error_handler(fatal_error_handler, nullptr);});
 
   CIndexer *CIdxr = new CIndexer();
   if (excludeDeclarationsFromPCH)
@@ -6959,7 +6952,7 @@ Logger &cxindex::Logger::operator<<(cons
 cxindex::Logger::~Logger() {
   LogOS.flush();
 
-  llvm::sys::ScopedLock L(EnableMultithreadingMutex);
+  llvm::sys::ScopedLock L(LoggingMutex);
 
   static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime();
 





More information about the cfe-commits mailing list