[PATCH] D41410: [WebAssembly] Apply data relocation in parallel. NFC.
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 12:31:30 PST 2017
sbc100 updated this revision to Diff 127585.
sbc100 added a comment.
rebase
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41410
Files:
wasm/OutputSections.cpp
wasm/OutputSections.h
wasm/OutputSegment.h
Index: wasm/OutputSegment.h
===================================================================
--- wasm/OutputSegment.h
+++ wasm/OutputSegment.h
@@ -11,6 +11,7 @@
#define LLD_WASM_OUTPUT_SEGMENT_H
#include "InputSegment.h"
+#include "WriterUtils.h"
#include "lld/Common/ErrorHandler.h"
#include "llvm/Object/Wasm.h"
@@ -39,6 +40,7 @@
uint32_t Alignment = 0;
uint32_t StartVA = 0;
std::vector<const InputSegment *> InputSegments;
+ std::vector<OutputRelocation> OutRelocations;
// Sum of the size of the all the input segments
uint32_t Size = 0;
Index: wasm/OutputSections.h
===================================================================
--- wasm/OutputSections.h
+++ wasm/OutputSections.h
@@ -126,11 +126,10 @@
explicit DataSection(ArrayRef<OutputSegment *> Segments);
size_t getSize() const override { return Header.size() + BodySize; }
void writeTo(uint8_t *Buf) override;
- uint32_t numRelocations() const override { return Relocations.size(); }
+ uint32_t numRelocations() const override;
void writeRelocations(raw_ostream &OS) const override;
protected:
- std::vector<OutputRelocation> Relocations;
ArrayRef<OutputSegment *> Segments;
std::string DataSectionHeader;
size_t BodySize = 0;
Index: wasm/OutputSections.cpp
===================================================================
--- wasm/OutputSections.cpp
+++ wasm/OutputSections.cpp
@@ -109,10 +109,11 @@
}
static void applyRelocations(uint8_t *Buf, ArrayRef<OutputRelocation> Relocs) {
+ if (!Relocs.size())
+ return;
log("applyRelocations: count=" + Twine(Relocs.size()));
- for (const OutputRelocation &Reloc : Relocs) {
+ for (const OutputRelocation &Reloc : Relocs)
applyRelocation(Buf, Reloc);
- }
}
// Relocations contain an index into the function, global or table index
@@ -251,8 +252,7 @@
PayloadSize);
log("applying relocations for: " + File->getName());
- if (File->CodeRelocations.size())
- applyRelocations(ContentsStart, File->CodeRelocations);
+ applyRelocations(ContentsStart, File->CodeRelocations);
});
}
@@ -293,8 +293,8 @@
uint32_t OutputOffset = Segment->getSectionOffset() +
Segment->Header.size() +
InputSeg->getOutputSegmentOffset();
- calcRelocations(*InputSeg->File, InputSeg->Relocations, Relocations,
- OutputOffset - InputOffset);
+ calcRelocations(*InputSeg->File, InputSeg->Relocations,
+ Segment->OutRelocations, OutputOffset - InputOffset);
}
BodySize += Segment->Size;
}
@@ -328,12 +328,20 @@
Input->getOutputSegmentOffset(),
Content.data(), Content.size());
}
+ applyRelocations(ContentsStart, Segment->OutRelocations);
});
- applyRelocations(ContentsStart, Relocations);
+}
+
+uint32_t DataSection::numRelocations() const {
+ uint32_t Count = 0;
+ for (const OutputSegment *Seg: Segments)
+ Count += Seg->OutRelocations.size();
+ return Count;
}
void DataSection::writeRelocations(raw_ostream &OS) const {
- for (const OutputRelocation &Reloc : Relocations)
- writeReloc(OS, Reloc);
+ for (const OutputSegment *Seg: Segments)
+ for (const OutputRelocation &Reloc : Seg->OutRelocations)
+ writeReloc(OS, Reloc);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41410.127585.patch
Type: text/x-patch
Size: 3336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171219/749d1482/attachment.bin>
More information about the llvm-commits
mailing list