diff options
author | Zachary Turner <zturner@google.com> | 2016-08-29 19:30:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-08-29 19:30:26 +0000 |
commit | 9b1669ae353e02c0fdbbe1ac181f18a453e98b35 (patch) | |
tree | 16f3e87071c6950faff8d8e8204d0ea7bfaa7903 /lldb/source/Core/Address.cpp | |
parent | 3c4f6bf654b3b9308f9d805d5ae7b3b4ad20f63d (diff) | |
download | bcm5719-llvm-9b1669ae353e02c0fdbbe1ac181f18a453e98b35.tar.gz bcm5719-llvm-9b1669ae353e02c0fdbbe1ac181f18a453e98b35.zip |
Remove std::atomic from lldb::Address.
std::atomic<uint64_t> requires 64-bit alignment in order to
guarantee atomicity. Normally the compiler is pretty good about
aligning types, but an exception to this is when the type is
passed by value as a function parameter. In this case, if your
stack is 4-byte aligned, most modern compilers (including clang
as of LLVM 4.0) fail to align the type, rendering the atomicity
ineffective.
A deeper investigation of the class's implementation suggests
that the use of atomic was in vain anyway, because if the class
were to be shared amongst multiple threads, there were already
other data races present, and that the proper way to ensure
thread-safe access to this data would be to use a mutex from a
higher level.
Since the std::atomic was not serving its intended purpose anyway,
and since the presence of it generates compiler errors on some
platforms that cannot be workaround, we remove std::atomic from
Address here. Although unlikely, if data races do resurface
the proper fix should involve a mutex from a higher level, or an
attempt to limit the Address's access to a single thread.
llvm-svn: 279994
Diffstat (limited to 'lldb/source/Core/Address.cpp')
-rw-r--r-- | lldb/source/Core/Address.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index f3ea1718d6f..2ef5bbee836 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -235,7 +235,7 @@ Address::operator= (const Address& rhs) if (this != &rhs) { m_section_wp = rhs.m_section_wp; - m_offset = rhs.m_offset.load(); + m_offset = rhs.m_offset; } return *this; } @@ -429,7 +429,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum if (section_sp) { section_sp->DumpName(s); - s->Printf (" + %" PRIu64, m_offset.load()); + s->Printf (" + %" PRIu64, m_offset); } else { |