[PATCH] D97654: [lld][WebAssembly] Minor refactor in preparation for SHF_STRINGS supports. NFC.
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 16:19:09 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d09e1d7cf27: [lld][WebAssembly] Minor refactor in preparation for SHF_STRINGS supports. NFC. (authored by sbc100).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97654/new/
https://reviews.llvm.org/D97654
Files:
lld/wasm/InputChunks.h
lld/wasm/OutputSegment.h
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -890,12 +890,13 @@
}
bool first = true;
for (InputSegment *inSeg : s->inputSegments) {
- uint32_t alignment = first ? s->alignment : 0;
+ if (first)
+ inSeg->alignment = std::max(inSeg->alignment, s->alignment);
first = false;
#ifndef NDEBUG
uint64_t oldVA = inSeg->getVA();
#endif
- combined->addInputSegment(inSeg, alignment);
+ combined->addInputSegment(inSeg);
#ifndef NDEBUG
uint64_t newVA = inSeg->getVA();
assert(oldVA == newVA);
Index: lld/wasm/OutputSegment.h
===================================================================
--- lld/wasm/OutputSegment.h
+++ lld/wasm/OutputSegment.h
@@ -22,8 +22,8 @@
public:
OutputSegment(StringRef n) : name(n) {}
- void addInputSegment(InputSegment *inSeg, uint32_t forceAlignment = 0) {
- uint32_t segAlign = std::max(forceAlignment, inSeg->getAlignment());
+ void addInputSegment(InputSegment *inSeg) {
+ uint32_t segAlign = inSeg->alignment;
alignment = std::max(alignment, segAlign);
inputSegments.push_back(inSeg);
size = llvm::alignTo(size, 1ULL << segAlign);
Index: lld/wasm/InputChunks.h
===================================================================
--- lld/wasm/InputChunks.h
+++ lld/wasm/InputChunks.h
@@ -42,7 +42,7 @@
virtual uint32_t getSize() const { return data().size(); }
virtual uint32_t getInputSize() const { return getSize(); };
- virtual void writeTo(uint8_t *sectionStart) const;
+ virtual void writeTo(uint8_t *buf) const;
ArrayRef<WasmRelocation> getRelocations() const { return relocations; }
void setRelocations(ArrayRef<WasmRelocation> rs) { relocations = rs; }
@@ -98,13 +98,14 @@
class InputSegment : public InputChunk {
public:
InputSegment(const WasmSegment &seg, ObjFile *f)
- : InputChunk(f, InputChunk::DataSegment), segment(seg) {}
+ : InputChunk(f, InputChunk::DataSegment), segment(seg) {
+ alignment = segment.Data.Alignment;
+ }
static bool classof(const InputChunk *c) { return c->kind() == DataSegment; }
void generateRelocationCode(raw_ostream &os) const;
- uint32_t getAlignment() const { return segment.Data.Alignment; }
StringRef getName() const override { return segment.Data.Name; }
StringRef getDebugName() const override { return StringRef(); }
uint32_t getComdat() const override { return segment.Data.Comdat; }
@@ -114,7 +115,8 @@
uint64_t getVA(uint64_t offset = 0) const;
const OutputSegment *outputSeg = nullptr;
- int32_t outputSegmentOffset = 0;
+ uint32_t outputSegmentOffset = 0;
+ uint32_t alignment = 0;
protected:
ArrayRef<uint8_t> data() const override { return segment.Data.Content; }
@@ -137,7 +139,7 @@
c->kind() == InputChunk::SyntheticFunction;
}
- void writeTo(uint8_t *sectionStart) const override;
+ void writeTo(uint8_t *buf) const override;
StringRef getName() const override { return function->SymbolName; }
StringRef getDebugName() const override { return function->DebugName; }
llvm::Optional<StringRef> getExportName() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97654.327316.patch
Type: text/x-patch
Size: 3234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210302/74c5ccee/attachment.bin>
More information about the llvm-commits
mailing list