[llvm-commits] [llvm] r73643 - /llvm/trunk/lib/VMCore/Mangler.cpp
Owen Anderson
resistor at mac.com
Wed Jun 17 15:01:09 PDT 2009
Author: resistor
Date: Wed Jun 17 17:01:09 2009
New Revision: 73643
URL: http://llvm.org/viewvc/llvm-project?rev=73643&view=rev
Log:
Use atomic increment here.
Modified:
llvm/trunk/lib/VMCore/Mangler.cpp
Modified: llvm/trunk/lib/VMCore/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=73643&r1=73642&r2=73643&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Mangler.cpp (original)
+++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jun 17 17:01:09 2009
@@ -14,6 +14,7 @@
#include "llvm/Support/Mangler.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
+#include "llvm/System/Atomic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
@@ -164,8 +165,12 @@
} else if (!GV->hasName()) {
// Must mangle the global into a unique ID.
unsigned TypeUniqueID = getTypeID(GV->getType());
- static unsigned GlobalID = 0;
- Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++);
+ static uint32_t GlobalID = 0;
+
+ unsigned OldID = GlobalID;
+ sys::AtomicIncrement(&GlobalID);
+
+ Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(OldID);
} else {
if (GV->hasPrivateLinkage())
Name = makeNameProper(GV->getName() + Suffix, Prefix, PrivatePrefix);
More information about the llvm-commits
mailing list