[lld] 87099a0 - [lld][WebAssembly] Remove unnecessary accessor methods. NFC
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 11:43:50 PDT 2022
Author: Sam Clegg
Date: 2022-06-03T11:43:44-07:00
New Revision: 87099a0438ade5cf0df1dda21183628ee3b49395
URL: https://github.com/llvm/llvm-project/commit/87099a0438ade5cf0df1dda21183628ee3b49395
DIFF: https://github.com/llvm/llvm-project/commit/87099a0438ade5cf0df1dda21183628ee3b49395.diff
LOG: [lld][WebAssembly] Remove unnecessary accessor methods. NFC
This is less code, and matches more closely the ELF linker.
Differential Revision: https://reviews.llvm.org/D126979
Added:
Modified:
lld/wasm/InputChunks.cpp
lld/wasm/InputChunks.h
lld/wasm/OutputSegment.cpp
lld/wasm/SyntheticSections.cpp
lld/wasm/Writer.cpp
Removed:
################################################################################
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index 332382c907b7c..34560ce9ca0f8 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -51,7 +51,7 @@ bool relocIs64(uint8_t relocType) {
}
std::string toString(const wasm::InputChunk *c) {
- return (toString(c->file) + ":(" + c->getName() + ")").str();
+ return (toString(c->file) + ":(" + c->name + ")").str();
}
namespace wasm {
@@ -196,14 +196,14 @@ uint64_t InputChunk::getTombstone() const {
}
void InputFunction::setFunctionIndex(uint32_t index) {
- LLVM_DEBUG(dbgs() << "InputFunction::setFunctionIndex: " << getName()
- << " -> " << index << "\n");
+ LLVM_DEBUG(dbgs() << "InputFunction::setFunctionIndex: " << name << " -> "
+ << index << "\n");
assert(!hasFunctionIndex());
functionIndex = index;
}
void InputFunction::setTableIndex(uint32_t index) {
- LLVM_DEBUG(dbgs() << "InputFunction::setTableIndex: " << getName() << " -> "
+ LLVM_DEBUG(dbgs() << "InputFunction::setTableIndex: " << name << " -> "
<< index << "\n");
assert(!hasTableIndex());
tableIndex = index;
@@ -271,7 +271,7 @@ void InputFunction::calculateSize() {
if (!file || !config->compressRelocations)
return;
- LLVM_DEBUG(dbgs() << "calculateSize: " << getName() << "\n");
+ LLVM_DEBUG(dbgs() << "calculateSize: " << name << "\n");
const uint8_t *secStart = file->codeSection->Content.data();
const uint8_t *funcStart = secStart + getInputSectionOffset();
@@ -318,7 +318,7 @@ void InputFunction::writeCompressed(uint8_t *buf) const {
decodeULEB128(funcStart, &count);
funcStart += count;
- LLVM_DEBUG(dbgs() << "write func: " << getName() << "\n");
+ LLVM_DEBUG(dbgs() << "write func: " << name << "\n");
buf += encodeULEB128(compressedFuncSize, buf);
const uint8_t *lastRelocEnd = funcStart;
for (const WasmRelocation &rel : relocations) {
@@ -339,7 +339,7 @@ void InputFunction::writeCompressed(uint8_t *buf) const {
uint64_t InputChunk::getChunkOffset(uint64_t offset) const {
if (const auto *ms = dyn_cast<MergeInputChunk>(this)) {
- LLVM_DEBUG(dbgs() << "getChunkOffset(merged): " << getName() << "\n");
+ LLVM_DEBUG(dbgs() << "getChunkOffset(merged): " << name << "\n");
LLVM_DEBUG(dbgs() << "offset: " << offset << "\n");
LLVM_DEBUG(dbgs() << "parentOffset: " << ms->getParentOffset(offset)
<< "\n");
@@ -361,7 +361,7 @@ uint64_t InputChunk::getVA(uint64_t offset) const {
// This is only called when generating shared libraries (PIC) where address are
// not known at static link time.
void InputChunk::generateRelocationCode(raw_ostream &os) const {
- LLVM_DEBUG(dbgs() << "generating runtime relocations: " << getName()
+ LLVM_DEBUG(dbgs() << "generating runtime relocations: " << name
<< " count=" << relocations.size() << "\n");
bool is64 = config->is64.getValueOr(false);
diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index 73c5f4fb1f890..f9626160976ce 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -49,8 +49,6 @@ class InputChunk {
StringRef name;
StringRef debugName;
- StringRef getName() const { return name; }
- StringRef getDebugName() const { return debugName; }
Kind kind() const { return (Kind)sectionKind; }
uint32_t getSize() const;
diff --git a/lld/wasm/OutputSegment.cpp b/lld/wasm/OutputSegment.cpp
index c09d5c30a0f6b..86b538403391b 100644
--- a/lld/wasm/OutputSegment.cpp
+++ b/lld/wasm/OutputSegment.cpp
@@ -23,8 +23,8 @@ void OutputSegment::addInputSegment(InputChunk *inSeg) {
alignment = std::max(alignment, inSeg->alignment);
inputSegments.push_back(inSeg);
size = llvm::alignTo(size, 1ULL << inSeg->alignment);
- LLVM_DEBUG(dbgs() << "addInputSegment: " << inSeg->getName()
- << " oname=" << name << " size=" << inSeg->getSize()
+ LLVM_DEBUG(dbgs() << "addInputSegment: " << inSeg->name << " oname=" << name
+ << " size=" << inSeg->getSize()
<< " align=" << inSeg->alignment << " at:" << size << "\n");
inSeg->outputSeg = this;
inSeg->outputSegmentOffset = size;
@@ -75,7 +75,7 @@ void OutputSegment::finalizeInputSegments() {
size = 0;
for (InputChunk *seg : inputSegments) {
size = llvm::alignTo(size, 1ULL << seg->alignment);
- LLVM_DEBUG(llvm::dbgs() << "outputSegmentOffset set: " << seg->getName()
+ LLVM_DEBUG(llvm::dbgs() << "outputSegmentOffset set: " << seg->name
<< " -> " << size << "\n");
seg->outputSegmentOffset = size;
size += seg->getSize();
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 6dde7469f6ee8..2d8fb0de6489e 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -735,7 +735,7 @@ unsigned NameSection::numNamedFunctions() const {
unsigned numNames = out.importSec->getNumImportedFunctions();
for (const InputFunction *f : out.functionSec->inputFunctions)
- if (!f->getName().empty() || !f->getDebugName().empty())
+ if (!f->name.empty() || !f->debugName.empty())
++numNames;
return numNames;
@@ -779,12 +779,12 @@ void NameSection::writeBody() {
}
}
for (const InputFunction *f : out.functionSec->inputFunctions) {
- if (!f->getName().empty()) {
+ if (!f->name.empty()) {
writeUleb128(sub.os, f->getFunctionIndex(), "func index");
- if (!f->getDebugName().empty()) {
- writeStr(sub.os, f->getDebugName(), "symbol name");
+ if (!f->debugName.empty()) {
+ writeStr(sub.os, f->debugName, "symbol name");
} else {
- writeStr(sub.os, maybeDemangleSymbol(f->getName()), "symbol name");
+ writeStr(sub.os, maybeDemangleSymbol(f->name), "symbol name");
}
}
}
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 4e254717e3b9c..4da324351df28 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -130,7 +130,7 @@ void Writer::calculateCustomSections() {
// Exclude COMDAT sections that are not selected for inclusion
if (section->discarded)
continue;
- StringRef name = section->getName();
+ StringRef name = section->name;
// These custom sections are known the linker and synthesized rather than
// blindly copied.
if (name == "linking" || name == "name" || name == "producers" ||
@@ -859,18 +859,17 @@ static StringRef getOutputDataSegmentName(const InputChunk &seg) {
// 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 seg.name;
+ if (seg.name.startswith(".text."))
return ".text";
- if (name.startswith(".data."))
+ if (seg.name.startswith(".data."))
return ".data";
- if (name.startswith(".bss."))
+ if (seg.name.startswith(".bss."))
return ".bss";
- if (name.startswith(".rodata."))
+ if (seg.name.startswith(".rodata."))
return ".rodata";
- return name;
+ return seg.name;
}
OutputSegment *Writer::createOutputSegment(StringRef name) {
@@ -952,7 +951,7 @@ void Writer::combineOutputSegments() {
combined->addInputSegment(inSeg);
#ifndef NDEBUG
uint64_t newVA = inSeg->getVA();
- LLVM_DEBUG(dbgs() << "added input segment. name=" << inSeg->getName()
+ LLVM_DEBUG(dbgs() << "added input segment. name=" << inSeg->name
<< " oldVA=" << oldVA << " newVA=" << newVA << "\n");
assert(oldVA == newVA);
#endif
More information about the llvm-commits
mailing list