[lld] r234628 - Fix minor threading issue.
Rui Ueyama
ruiu at google.com
Fri Apr 10 12:55:35 PDT 2015
Author: ruiu
Date: Fri Apr 10 14:55:35 2015
New Revision: 234628
URL: http://llvm.org/viewvc/llvm-project?rev=234628&view=rev
Log:
Fix minor threading issue.
Because calls of applyRelocation is parallelized, all functions
called from that need to be thread-safe. This piece of code
didn't use any synchronization mechanism, so it was not safe.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=234628&r1=234627&r2=234628&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Fri Apr 10 14:55:35 2015
@@ -82,17 +82,18 @@ public:
Section<ELFT> *getSDataSection() const { return _sdataSection; }
uint64_t getGOTSymAddr() {
- if (!_gotSymAtom.hasValue())
- _gotSymAtom = this->findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
- if (*_gotSymAtom)
- return (*_gotSymAtom)->_virtualAddr;
- return 0;
+ std::call_once(_gotOnce, [this]() {
+ if (AtomLayout *got = this->findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"))
+ _gotAddr = got->_virtualAddr;
+ });
+ return _gotAddr;
}
private:
llvm::BumpPtrAllocator _alloc;
SDataSection<ELFT> *_sdataSection = nullptr;
- llvm::Optional<AtomLayout *> _gotSymAtom;
+ uint64_t _gotAddr = 0;
+ std::once_flag _gotOnce;
};
/// \brief TargetHandler for Hexagon
More information about the llvm-commits
mailing list