diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-26 18:09:03 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-26 18:09:03 +0000 |
commit | 4a032792311b88becaa86455c91d36b5e853348d (patch) | |
tree | daabe0ed8957b5d68ce27c83425437ed3f45881f | |
parent | 5960e6d97401674604473519b24a02300cb12f17 (diff) | |
download | bcm5719-llvm-4a032792311b88becaa86455c91d36b5e853348d.tar.gz bcm5719-llvm-4a032792311b88becaa86455c91d36b5e853348d.zip |
Use atomic operations for accessing this global counter.
llvm-svn: 74294
-rw-r--r-- | llvm/lib/Support/Annotation.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Support/Annotation.cpp b/llvm/lib/Support/Annotation.cpp index 9c3efa37d86..b7780433c06 100644 --- a/llvm/lib/Support/Annotation.cpp +++ b/llvm/lib/Support/Annotation.cpp @@ -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); } |