[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
This commit is contained in:
Sam Clegg 2022-06-03 10:47:53 -07:00
parent 389c0b81d3
commit 87099a0438
5 changed files with 24 additions and 27 deletions

View File

@ -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);

View File

@ -49,8 +49,6 @@ public:
StringRef name;
StringRef debugName;
StringRef getName() const { return name; }
StringRef getDebugName() const { return debugName; }
Kind kind() const { return (Kind)sectionKind; }
uint32_t getSize() const;

View File

@ -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();

View File

@ -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");
}
}
}

View File

@ -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