mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
Use atomic operations for accessing this global counter.
llvm-svn: 74294
This commit is contained in:
parent
46eb5a7a2d
commit
1069071612
@ -68,9 +68,12 @@ AnnotationID AnnotationManager::getID(const char *Name) { // Name -> ID
|
||||
if (I == E) {
|
||||
sys::SmartScopedWriter<true> Writer(&*AnnotationsLock);
|
||||
I = IDMap->find(Name);
|
||||
if (I == IDMap->end())
|
||||
(*IDMap)[Name] = IDCounter++; // Add a new element
|
||||
return AnnotationID(IDCounter-1);
|
||||
if (I == IDMap->end()) {
|
||||
unsigned newCount = sys::AtomicIncrement(&IDCounter);
|
||||
(*IDMap)[Name] = newCount-1; // Add a new element
|
||||
return AnnotationID(newCount-1);
|
||||
} else
|
||||
return AnnotationID(I->second);
|
||||
}
|
||||
return AnnotationID(I->second);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user