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

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 10:56:47 PST 2018


ruiu added inline comments.


================
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);
----------------
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.


================
Comment at: wasm/Writer.cpp:807
 
+  if (Config->PrintGcSections) {
+    for (const ObjFile *Obj : Symtab->ObjectFiles) {
----------------
It seems a bit too late to do this kind of stuff, since this is a writer. Is there any way to detect liveness of globals earlier than it is now, move code to MarkLive, and also move this code to MarkLive?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44311





More information about the llvm-commits mailing list