[lld] r308728 - [ELF] Avoid data race in ObjectFile<ELFT>::getDILineInfo().
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 04:26:08 PDT 2017
Author: ikudrin
Date: Fri Jul 21 04:26:08 2017
New Revision: 308728
URL: http://llvm.org/viewvc/llvm-project?rev=308728&view=rev
Log:
[ELF] Avoid data race in ObjectFile<ELFT>::getDILineInfo().
Differential Revision: https://reviews.llvm.org/D35537
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=308728&r1=308727&r2=308728&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Jul 21 04:26:08 2017
@@ -80,8 +80,7 @@ template <class ELFT> void elf::ObjectFi
template <class ELFT>
Optional<DILineInfo> elf::ObjectFile<ELFT>::getDILineInfo(InputSectionBase *S,
uint64_t Offset) {
- if (!DwarfLine)
- initializeDwarfLine();
+ llvm::call_once(InitDwarfLine, [this]() { initializeDwarfLine(); });
// The offset to CU is 0.
const DWARFDebugLine::LineTable *Tbl = DwarfLine->getLineTable(0);
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=308728&r1=308727&r2=308728&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Fri Jul 21 04:26:08 2017
@@ -24,6 +24,7 @@
#include "llvm/Object/Archive.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Support/Threading.h"
#include <map>
@@ -212,6 +213,7 @@ private:
// single object file, so we cache debugging information in order to
// parse it only once for each object file we link.
std::unique_ptr<llvm::DWARFDebugLine> DwarfLine;
+ llvm::once_flag InitDwarfLine;
};
// LazyObjectFile is analogous to ArchiveFile in the sense that
More information about the llvm-commits
mailing list