summaryrefslogtreecommitdiff
path: root/lib/Support/Annotation.cpp
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
commitf859468f5a21b6952ab62917777f9fb3bba57003 (patch)
tree9794dc36f22f2a2b3f8063829d8a9b3a7794acc8 /lib/Support/Annotation.cpp
parentf76359690a7035ad21498f2ba6be6991d3b2032d (diff)
Diffstat (limited to 'lib/Support/Annotation.cpp')
-rw-r--r--lib/Support/Annotation.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp
index 9c3efa37d867..b7780433c062 100644
--- a/lib/Support/Annotation.cpp
+++ b/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);
}