[lld] r325535 - [WebAssembly] Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 14:29:48 PST 2018


Author: ruiu
Date: Mon Feb 19 14:29:48 2018
New Revision: 325535

URL: http://llvm.org/viewvc/llvm-project?rev=325535&view=rev
Log:
[WebAssembly] Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.

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

Differential Revision: https://reviews.llvm.org/D43434

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

Modified: lld/trunk/test/wasm/gc-sections.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/gc-sections.ll?rev=325535&r1=325534&r2=325535&view=diff
==============================================================================
--- lld/trunk/test/wasm/gc-sections.ll (original)
+++ lld/trunk/test/wasm/gc-sections.ll Mon Feb 19 14:29:48 2018
@@ -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"
 

Modified: lld/trunk/wasm/InputChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.cpp?rev=325535&r1=325534&r2=325535&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.cpp (original)
+++ lld/trunk/wasm/InputChunks.cpp Mon Feb 19 14:29:48 2018
@@ -22,6 +22,10 @@ using namespace llvm::support::endian;
 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();

Modified: lld/trunk/wasm/InputChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.h?rev=325535&r1=325534&r2=325535&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.h (original)
+++ lld/trunk/wasm/InputChunks.h Mon Feb 19 14:29:48 2018
@@ -174,6 +174,8 @@ protected:
 };
 
 } // namespace wasm
+
+std::string toString(const wasm::InputChunk *);
 } // namespace lld
 
 #endif // LLD_WASM_INPUT_CHUNKS_H

Modified: lld/trunk/wasm/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/MarkLive.cpp?rev=325535&r1=325534&r2=325535&view=diff
==============================================================================
--- lld/trunk/wasm/MarkLive.cpp (original)
+++ lld/trunk/wasm/MarkLive.cpp Mon Feb 19 14:29:48 2018
@@ -91,17 +91,13 @@ void lld::wasm::markLive() {
 
   // 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));
     }
   }
 }




More information about the llvm-commits mailing list