Index: lld/test/wasm/gc-sections.ll =================================================================== --- lld/test/wasm/gc-sections.ll +++ lld/test/wasm/gc-sections.ll @@ -1,9 +1,9 @@ ; RUN: llc -filetype=obj %s -o %t.o ; RUN: wasm-ld -print-gc-sections -o %t1.wasm %t.o | FileCheck %s -check-prefix=PRINT-GC -; PRINT-GC: removing unused section 'unused_function' in file '{{.*}}' -; PRINT-GC-NOT: removing unused section 'used_function' in file '{{.*}}' -; PRINT-GC: removing unused section '.data.unused_data' in file '{{.*}}' -; PRINT-GC-NOT: removing unused section '.data.used_data' in file '{{.*}}' +; PRINT-GC: removing unused section {{.*}}:(unused_function) +; PRINT-GC-NOT: removing unused section {{.*}}:(used_function) +; PRINT-GC: removing unused section {{.*}}:(.data.unused_data) +; PRINT-GC-NOT: removing unused section {{.*}}:(.data.used_data) target triple = "wasm32-unknown-unknown-wasm" Index: lld/wasm/InputChunks.h =================================================================== --- lld/wasm/InputChunks.h +++ lld/wasm/InputChunks.h @@ -174,6 +174,8 @@ }; } // namespace wasm + +std::string toString(const wasm::InputChunk *); } // namespace lld #endif // LLD_WASM_INPUT_CHUNKS_H Index: lld/wasm/InputChunks.cpp =================================================================== --- lld/wasm/InputChunks.cpp +++ lld/wasm/InputChunks.cpp @@ -22,6 +22,10 @@ using namespace lld; using namespace lld::wasm; +std::string lld::toString(const InputChunk *C) { + return (toString(C->File) + ":(" + C->getName() + ")").str(); +} + uint32_t InputSegment::translateVA(uint32_t Address) const { assert(Address >= startVA() && Address < endVA()); int32_t Delta = OutputSeg->StartVA + OutputSegmentOffset - startVA(); Index: lld/wasm/MarkLive.cpp =================================================================== --- lld/wasm/MarkLive.cpp +++ lld/wasm/MarkLive.cpp @@ -91,17 +91,13 @@ // Report garbage-collected sections. if (Config->PrintGcSections) { - auto CheckChunk = [](const InputChunk *C) { - if (!C->Live) - message("removing unused section '" + C->getName() + "' in file '" + - C->File->getName() + "'"); - }; - for (const ObjFile *Obj : Symtab->ObjectFiles) { for (InputChunk *C : Obj->Functions) - CheckChunk(C); + if (!C->Live) + message("removing unused section " + toString(C)); for (InputChunk *C : Obj->Segments) - CheckChunk(C); + if (!C->Live) + message("removing unused section " + toString(C)); } } }