[PATCH] D85062: [WebAssembly] GC constructor functions in otherwise unused archive objects

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 19:25:36 PDT 2020


sunfish added a comment.

In D85062#2188643 <https://reviews.llvm.org/D85062#2188643>, @sbc100 wrote:

> To be clear this change only relates to object files at are part of `ar` archives and are not part of the link?     Perhaps mention that in the PR title/description.

Yes, this relates to functions in objects which don't, after GC, contribute any functions to the link. I've now added "archive" to the title.



================
Comment at: lld/wasm/InputFiles.h:103
+    if (archiveName.empty())
+      markLive();
   }
----------------
sbc100 wrote:
> My understanding is that any file that is created as an ObjFile is by definition live. and that all files in `symtab->objectFiles` are also by definition live.
> 
> Archive files don't create any `ObjFile`s until they are pulled into the link for some reason (i.e. they are live).
> 
> What am I missing here?
There are effectively two GC algorithms in wasm-ld today. The first selects the objects that aren't in archives, plus the objects in archives they (transitively) reference. The second one is MarkLive.cpp, which selects exported functions, plus functions they (transitively) reference.

What this patch is saying is, if a constructor function gets pulled in because its object is selected in the first phase, but MarkLive.cpp's GC determines that no functions in that object are transitively called from an export in the second phase, the constructor doesn't need to be called.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85062/new/

https://reviews.llvm.org/D85062



More information about the llvm-commits mailing list