[lld] r237857 - [LLD] Make lastOrdinal atomic to avoid race conditions.
Lang Hames
lhames at gmail.com
Wed May 20 16:44:37 PDT 2015
Author: lhames
Date: Wed May 20 18:44:37 2015
New Revision: 237857
URL: http://llvm.org/viewvc/llvm-project?rev=237857&view=rev
Log:
[LLD] Make lastOrdinal atomic to avoid race conditions.
No test case: We don't have a good way to test race conditions.
Modified:
lld/trunk/include/lld/Core/Simple.h
Modified: lld/trunk/include/lld/Core/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Simple.h?rev=237857&r1=237856&r2=237857&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Simple.h (original)
+++ lld/trunk/include/lld/Core/Simple.h Wed May 20 18:44:37 2015
@@ -23,6 +23,7 @@
#include "lld/Core/UndefinedAtom.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
+#include <atomic>
namespace lld {
@@ -206,7 +207,7 @@ namespace lld {
class SimpleDefinedAtom : public DefinedAtom {
public:
explicit SimpleDefinedAtom(const File &f) : _file(f) {
- static uint32_t lastOrdinal = 0;
+ static std::atomic<uint32_t> lastOrdinal(0);
_ordinal = lastOrdinal++;
_references.setAllocator(&f.allocator());
}
More information about the llvm-commits
mailing list