[PATCH] D43434: Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 17 15:47:15 PST 2018


ruiu created this revision.
ruiu added a reviewer: sbc100.
Herald added subscribers: sunfish, aheejin, jfb.

Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.


https://reviews.llvm.org/D43434

Files:
  lld/test/wasm/gc-sections.ll
  lld/wasm/InputChunks.cpp
  lld/wasm/InputChunks.h
  lld/wasm/MarkLive.cpp


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43434.134822.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180217/f41058d9/attachment.bin>


More information about the llvm-commits mailing list