[lld] r182795 - Parallel write.
Michael J. Spencer
bigcheesegs at gmail.com
Tue May 28 12:09:57 PDT 2013
Author: mspencer
Date: Tue May 28 14:09:56 2013
New Revision: 182795
URL: http://llvm.org/viewvc/llvm-project?rev=182795&view=rev
Log:
Parallel write.
Modified:
lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=182795&r1=182794&r2=182795&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Tue May 28 14:09:56 2013
@@ -10,6 +10,7 @@
#define LLD_READER_WRITER_OUTPUT_ELF_WRITER_H
#include "lld/Core/Instrumentation.h"
+#include "lld/Core/Parallel.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
#include "lld/ReaderWriter/Writer.h"
@@ -279,6 +280,7 @@ void OutputELFWriter<ELFT>::createDefaul
template <class ELFT>
error_code OutputELFWriter<ELFT>::buildOutput(const File &file) {
+ ScopedTask buildTask(getDefaultDomain(), "ELF Writer buildOutput");
buildChunks(file);
// Create the default sections like the symbol table, string table, and the
@@ -328,9 +330,7 @@ error_code OutputELFWriter<ELFT>::buildO
template <class ELFT>
error_code OutputELFWriter<ELFT>::writeFile(const File &file, StringRef path) {
- ScopedTask buildTask(getDefaultDomain(), "ELF Writer buildOutput");
buildOutput(file);
- buildTask.end();
uint64_t totalSize = _shdrtab->fileOffset() + _shdrtab->fileSize();
@@ -378,7 +378,7 @@ error_code OutputELFWriter<ELFT>::writeF
_programHeader->write(this, *buffer);
for (auto section : _layout->sections())
- section->write(this, *buffer);
+ section->write(this, *buffer);
writeTask.end();
ScopedTask commitTask(getDefaultDomain(), "ELF Writer commit to disk");
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=182795&r1=182794&r2=182795&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue May 28 14:09:56 2013
@@ -16,6 +16,7 @@
#include "Writer.h"
#include "lld/Core/DefinedAtom.h"
+#include "lld/Core/Parallel.h"
#include "lld/Core/range.h"
#include "llvm/ADT/ArrayRef.h"
@@ -341,19 +342,19 @@ template <class ELFT>
void AtomSection<ELFT>::write(ELFWriter *writer,
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
- for (auto &ai : _atoms) {
+ parallel_for_each(_atoms.begin(), _atoms.end(), [&] (AtomLayout *ai) {
DEBUG_WITH_TYPE("Section",
llvm::dbgs() << "Writing atom: " << ai->_atom->name()
<< " | " << ai->_fileOffset << "\n");
const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom);
if ((definedAtom->contentType() == DefinedAtom::typeZeroFill) ||
(definedAtom->contentType() == DefinedAtom::typeZeroFillFast))
- continue;
+ return;
// Copy raw content of atom to file buffer.
llvm::ArrayRef<uint8_t> content = definedAtom->rawContent();
uint64_t contentSize = content.size();
if (contentSize == 0)
- continue;
+ return;
uint8_t *atomContent = chunkBuffer + ai->_fileOffset;
std::memcpy(atomContent, content.data(), contentSize);
const TargetRelocationHandler<ELFT> &relHandler =
@@ -361,7 +362,7 @@ void AtomSection<ELFT>::write(ELFWriter
.getRelocationHandler();
for (const auto ref : *definedAtom)
relHandler.applyRelocation(*writer, buffer, *ai, *ref);
- }
+ });
}
/// \brief A MergedSections represents a set of sections grouped by the same
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp?rev=182795&r1=182794&r2=182795&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp Tue May 28 14:09:56 2013
@@ -12,6 +12,7 @@
#include "lld/Core/File.h"
#include "lld/Core/Instrumentation.h"
+#include "lld/Core/Parallel.h"
#include "lld/Core/Pass.h"
#include "lld/Core/PassManager.h"
#include "lld/ReaderWriter/Simple.h"
More information about the llvm-commits
mailing list