[PATCH] D44311: [WebAssembly] Implement -print-gc-sections to test global GC

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 16:33:27 PST 2018


sbc100 added inline comments.


================
Comment at: wasm/InputGlobal.h:55
+  return (toString(G->File) + ":(" + G->getName() + ")").str();
+}
+
----------------
Non of this is needed if you don't include globals in the output of --print-gc-section.


================
Comment at: wasm/MarkLive.cpp:110
+      if (!C->Live)
+        message("removing unused section " + toString(C));
   }
----------------
Can you make this a separate change?


================
Comment at: wasm/Writer.cpp:790-791
+      } else if (Reloc.Type == R_WEBASSEMBLY_GLOBAL_INDEX_LEB &&
+                 Config->GcSections) {
         // Mark target global as live
         GlobalSymbol *Sym = File->getGlobalSymbol(Reloc.Index);
----------------
ruiu wrote:
> I believe you added `Config->GcSections` because if GC is off, all globals are alive by default and therefore we don't need to set that bit at all. Is this correct? If so, please add a comment.
I don't really consider what we are going here as GC of sections.  Its more like we are building the sythentic type and global section, and we always do it precisely based on what is needed.   There is no option to disable this, as there is no need to a more conservative approach AFAICT.

Perhaps it we rename Global->Live to Global->Used it will make the distinction more clear?

So I don't agree with this part of the change.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44311





More information about the llvm-commits mailing list