[PATCH] D41390: Wasm LLD: Don't write out discarded function symbols

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 05:50:58 PST 2017


ncw created this revision.
ncw added reviewers: ruiu, sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, mgorny, jfb.

This is small change, on the principle, "let's keep the commits small and take little baby steps in each commit".

APPLIES AFTER https://reviews.llvm.org/D41315 (Sam's commit "Output functions individually").

This beefs up Sam's change with a few lines of code taken from ELF-LLD, which has the notion of "discarded" input sections. We now have "discarded" InputSegments/InputFunctions.

As proof of concept, I've implemented discarding duplicate weak symbols. If two files both define the same function weakly, then the second copy shouldn't be written out, since all calls to it will go via relocations, and no relocations can touch the function if it's not reachable via any Symbols. Hence if every translation unit provides a function like "std::string::whatever" it will only be written out once.

The behaviour is covered by existing tests, which exercise the weak symbols code, and assert on the output.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41390

Files:
  test/wasm/weak-symbols.ll
  wasm/CMakeLists.txt
  wasm/InputFiles.cpp
  wasm/InputFiles.h
  wasm/InputFunction.cpp
  wasm/InputFunction.h
  wasm/InputSegment.cpp
  wasm/InputSegment.h
  wasm/SymbolTable.h
  wasm/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41390.127508.patch
Type: text/x-patch
Size: 9174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171219/272ac3aa/attachment.bin>


More information about the llvm-commits mailing list