[PATCH] D44440: [WebAssembly] Implement --print-gc-sections for synthetic functions

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 13 10:13:28 PDT 2018


ncw created this revision.
ncw added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.

Now that we have the synthetic undefined stubs, it is possible for synthetic functions to be GC'd, so we may as well indicate that for troubleshooting purposes


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44440

Files:
  test/wasm/undefined-weak-call.ll
  wasm/MarkLive.cpp


Index: wasm/MarkLive.cpp
===================================================================
--- wasm/MarkLive.cpp
+++ wasm/MarkLive.cpp
@@ -105,5 +105,8 @@
         if (!C->Live)
           message("removing unused section " + toString(C));
     }
+    for (InputChunk *C : Symtab->SyntheticFunctions)
+      if (!C->Live)
+        message("removing unused section " + toString(C));
   }
 }
Index: test/wasm/undefined-weak-call.ll
===================================================================
--- test/wasm/undefined-weak-call.ll
+++ test/wasm/undefined-weak-call.ll
@@ -1,5 +1,6 @@
 ; RUN: llc -filetype=obj %s -o %t.o
-; RUN: wasm-ld --check-signatures --no-entry %t.o -o %t.wasm
+; RUN: wasm-ld --check-signatures --no-entry --print-gc-sections %t.o \
+; RUN:     -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-GC %s
 ; RUN: obj2yaml %t.wasm | FileCheck %s
 
 ; Check that calling an undefined weak function generates an appropriate stub
@@ -12,6 +13,8 @@
 declare extern_weak void @weakFunc3(i32 %arg) ; different
 declare extern_weak void @weakFunc4()         ; should be GC'd as not called
 
+; CHECK-GC: removing unused section {{.*}}:(undefined function weakFunc4)
+
 define i32 @callWeakFuncs() {
   call void @weakFunc1()
   call void @weakFunc2()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44440.138221.patch
Type: text/x-patch
Size: 1266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180313/00d67c0a/attachment.bin>


More information about the llvm-commits mailing list