[PATCH] D126976: [lld][WebAssembly][NFC] Move getOutputSegmentName to InputChunk methods
Yuta Saito via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 10:28:32 PDT 2022
kateinoigakukun created this revision.
kateinoigakukun added a reviewer: sbc100.
Herald added subscribers: pmatos, asb, ecnelises, sunfish, jgravelle-google, dschuff.
Herald added a project: All.
kateinoigakukun requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
This patch is extracted from the https://reviews.llvm.org/D126950.
It renames `getOutputDataSegmentName` static function to `getOutputSegmentName`, and also place it in `InputChunk` to reuse it while GCing sections.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126976
Files:
lld/wasm/InputChunks.cpp
lld/wasm/InputChunks.h
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -854,25 +854,6 @@
out.tableSec->assignIndexes();
}
-static StringRef getOutputDataSegmentName(const InputChunk &seg) {
- // We always merge .tbss and .tdata into a single TLS segment so all TLS
- // symbols are be relative to single __tls_base.
- if (seg.isTLS())
- return ".tdata";
- StringRef name = seg.getName();
- if (!config->mergeDataSegments)
- return name;
- if (name.startswith(".text."))
- return ".text";
- if (name.startswith(".data."))
- return ".data";
- if (name.startswith(".bss."))
- return ".bss";
- if (name.startswith(".rodata."))
- return ".rodata";
- return name;
-}
-
OutputSegment *Writer::createOutputSegment(StringRef name) {
LLVM_DEBUG(dbgs() << "new segment: " << name << "\n");
OutputSegment *s = make<OutputSegment>(name);
@@ -889,7 +870,7 @@
for (InputChunk *segment : file->segments) {
if (!segment->live)
continue;
- StringRef name = getOutputDataSegmentName(*segment);
+ StringRef name = segment->getOutputSegmentName();
OutputSegment *s = nullptr;
// When running in relocatable mode we can't merge segments that are part
// of comdat groups since the ultimate linker needs to be able exclude or
Index: lld/wasm/InputChunks.h
===================================================================
--- lld/wasm/InputChunks.h
+++ lld/wasm/InputChunks.h
@@ -76,6 +76,7 @@
uint32_t getComdat() const { return comdat; }
StringRef getComdatName() const;
uint32_t getInputSectionOffset() const { return inputSectionOffset; }
+ StringRef getOutputSegmentName() const;
size_t getNumRelocations() const { return relocations.size(); }
void writeRelocations(llvm::raw_ostream &os) const;
Index: lld/wasm/InputChunks.cpp
===================================================================
--- lld/wasm/InputChunks.cpp
+++ lld/wasm/InputChunks.cpp
@@ -523,5 +523,24 @@
return UINT64_C(-1);
}
+StringRef InputChunk::getOutputSegmentName() const {
+ // We always merge .tbss and .tdata into a single TLS segment so all TLS
+ // symbols are be relative to single __tls_base.
+ if (isTLS())
+ return ".tdata";
+ StringRef name = getName();
+ if (!config->mergeDataSegments)
+ return name;
+ if (name.startswith(".text."))
+ return ".text";
+ if (name.startswith(".data."))
+ return ".data";
+ if (name.startswith(".bss."))
+ return ".bss";
+ if (name.startswith(".rodata."))
+ return ".rodata";
+ return name;
+}
+
} // namespace wasm
} // namespace lld
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126976.434061.patch
Type: text/x-patch
Size: 2662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220603/42ad72e6/attachment.bin>
More information about the llvm-commits
mailing list