diff --git a/llvm/include/llvm/ADT/ConcurrentHashtable.h b/llvm/include/llvm/ADT/ConcurrentHashtable.h index 6a943c5b062e7..0cc03cf7a692a 100644 --- a/llvm/include/llvm/ADT/ConcurrentHashtable.h +++ b/llvm/include/llvm/ADT/ConcurrentHashtable.h @@ -177,7 +177,7 @@ class ConcurrentHashTableByPtr { #if LLVM_ENABLE_THREADS // Lock bucket. - CurBucket.Guard.lock(); + std::scoped_lock Lock(CurBucket.Guard); #endif HashesPtr BucketHashes = CurBucket.Hashes; @@ -195,11 +195,6 @@ class ConcurrentHashTableByPtr { CurBucket.NumberOfEntries++; RehashBucket(CurBucket); - -#if LLVM_ENABLE_THREADS - CurBucket.Guard.unlock(); -#endif - return {NewData, true}; } @@ -208,10 +203,6 @@ class ConcurrentHashTableByPtr { KeyDataTy *EntryData = BucketEntries[CurEntryIdx]; if (Info::isEqual(Info::getKey(*EntryData), NewValue)) { // Already existed entry matched with inserted data is found. -#if LLVM_ENABLE_THREADS - CurBucket.Guard.unlock(); -#endif - return {EntryData, false}; } }