forked from OSchip/llvm-project
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
This commit is contained in:
parent
3c4f6bf654
commit
9b1669ae35
|
@ -12,7 +12,6 @@
|
|||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
#include <atomic>
|
||||
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
|
@ -119,7 +118,7 @@ public:
|
|||
//------------------------------------------------------------------
|
||||
Address (const Address& rhs) :
|
||||
m_section_wp (rhs.m_section_wp),
|
||||
m_offset(rhs.m_offset.load())
|
||||
m_offset(rhs.m_offset)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -556,7 +555,7 @@ protected:
|
|||
// Member variables.
|
||||
//------------------------------------------------------------------
|
||||
lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
|
||||
std::atomic<lldb::addr_t> m_offset; ///< Offset into section if \a m_section_wp is valid...
|
||||
lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid...
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Returns true if the m_section_wp once had a reference to a valid
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue