[lld][WebAssembly] Cleanup output of --verbose

Remove some unnecessary logging from wasm-ld when running under
`--verbose`.  Unlike `-debug` this logging is available in release
builds.  This change makes it little more minimal/readable.

Also, avoid compiling the `debugWrite` function in releaase builds
where it does nothing.  This should remove a lot debug strings from
the binary, and avoid having to construct unused debug strings at
runtime.

Differential Revision: https://reviews.llvm.org/D109583
This commit is contained in:
Sam Clegg 2021-09-10 04:46:03 -04:00
parent d727bd6962
commit 3a7bcba34b
7 changed files with 13 additions and 23 deletions

View File

@ -88,15 +88,6 @@ InputFile *createObjectFile(MemoryBufferRef mb, StringRef archiveName) {
fatal("unknown file type: " + mb.getBufferIdentifier());
}
void ObjFile::dumpInfo() const {
log("info for: " + toString(this) +
"\n Symbols : " + Twine(symbols.size()) +
"\n Function Imports : " + Twine(wasmObj->getNumImportedFunctions()) +
"\n Global Imports : " + Twine(wasmObj->getNumImportedGlobals()) +
"\n Tag Imports : " + Twine(wasmObj->getNumImportedTags()) +
"\n Table Imports : " + Twine(wasmObj->getNumImportedTables()));
}
// Relocations contain either symbol or type indices. This function takes a
// relocation and returns relocated index (i.e. translates from the input
// symbol/type space to the output symbol/type space).

View File

@ -116,8 +116,6 @@ public:
// Returns the underlying wasm file.
const WasmObjectFile *getWasmObj() const { return wasmObj.get(); }
void dumpInfo() const;
uint32_t calcNewIndex(const WasmRelocation &reloc) const;
uint64_t calcNewValue(const WasmRelocation &reloc, uint64_t tombstone,
const InputChunk *chunk) const;

View File

@ -101,8 +101,8 @@ void CodeSection::finalizeContents() {
}
void CodeSection::writeTo(uint8_t *buf) {
log("writing " + toString(*this));
log(" size=" + Twine(getSize()));
log("writing " + toString(*this) + " offset=" + Twine(offset) +
" size=" + Twine(getSize()));
log(" headersize=" + Twine(header.size()));
log(" codeheadersize=" + Twine(codeSectionHeader.size()));
buf += offset;
@ -187,8 +187,8 @@ void DataSection::finalizeContents() {
}
void DataSection::writeTo(uint8_t *buf) {
log("writing " + toString(*this) + " size=" + Twine(getSize()) +
" body=" + Twine(bodySize));
log("writing " + toString(*this) + " offset=" + Twine(offset) +
" size=" + Twine(getSize()) + " body=" + Twine(bodySize));
buf += offset;
// Write section header
@ -279,8 +279,8 @@ void CustomSection::finalizeContents() {
}
void CustomSection::writeTo(uint8_t *buf) {
log("writing " + toString(*this) + " size=" + Twine(getSize()) +
" chunks=" + Twine(inputSections.size()));
log("writing " + toString(*this) + " offset=" + Twine(offset) +
" size=" + Twine(getSize()) + " chunks=" + Twine(inputSections.size()));
assert(offset);
buf += offset;

View File

@ -33,10 +33,7 @@ public:
virtual ~OutputSection() = default;
StringRef getSectionName() const;
void setOffset(size_t newOffset) {
log("setOffset: " + toString(*this) + ": " + Twine(newOffset));
offset = newOffset;
}
void setOffset(size_t newOffset) { offset = newOffset; }
void createHeader(size_t bodySize);
virtual bool isNeeded() const { return true; }
virtual size_t getSize() const = 0;

View File

@ -1513,8 +1513,6 @@ void Writer::run() {
log("Global Imports : " + Twine(out.importSec->getNumImportedGlobals()));
log("Tag Imports : " + Twine(out.importSec->getNumImportedTags()));
log("Table Imports : " + Twine(out.importSec->getNumImportedTables()));
for (ObjFile *file : symtab->objectFiles)
file->dumpInfo();
}
createHeader();

View File

@ -80,9 +80,11 @@ std::string toString(const WasmTableType &type) {
}
namespace wasm {
#ifdef LLVM_DEBUG
void debugWrite(uint64_t offset, const Twine &msg) {
LLVM_DEBUG(dbgs() << format(" | %08lld: ", offset) << msg << "\n");
}
#endif
void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg) {
debugWrite(os.tell(), msg + "[" + utohexstr(number) + "]");

View File

@ -16,7 +16,11 @@
namespace lld {
namespace wasm {
#ifdef LLVM_DEBUG
void debugWrite(uint64_t offset, const Twine &msg);
#else
#define debugWrite(...) (void *)0
#endif
void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);