Garbage collect dllimported symbols.
authorRui Ueyama <ruiu@google.com>
Wed, 17 May 2017 00:35:50 +0000 (00:35 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 17 May 2017 00:35:50 +0000 (00:35 +0000)
commit02df7a6cf1874ecbf0f1ee50846cf8cb2e648b63
tree84bd22c6f13856cb5ee63db0d3212a6c8fa44a65
parent26342f915bd615900c652afd3c807a4fc195ac9f
Garbage collect dllimported symbols.

Summary:
Previously, the garbage collector (enabled by default or by explicitly
passing /opt:ref) did not kill dllimported symbols. As a result,
dllimported symbols could be added to resulting executables' dllimport
list even if no one was actually using them.

This patch implements dllexported symbol garbage collection. Just like
COMDAT sections, dllimported symbols now have Live bits to manage their
liveness, and MarkLive marks reachable dllimported symbols.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32950

Reviewers: pcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33264

llvm-svn: 303225
lld/COFF/InputFiles.cpp
lld/COFF/MarkLive.cpp
lld/COFF/Symbols.cpp
lld/COFF/Symbols.h
lld/COFF/Writer.cpp
lld/test/COFF/Inputs/import.yaml
lld/test/COFF/dllimport-gc.test [new file with mode: 0644]