[PATCH] D23488: ThinLTO: add early "dead-stripping" on the Index

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 14:27:17 PST 2016


tejohnson added a comment.

This is getting undefined references in the link of the SPEC C++ apps. Looking at one of the cases, it is caused by incorrectly determining that some references are dead when in fact they have a reference via the llvm.global_ctors variable. The index correctly reflects the chain of references starting at the llvm.global_ctors variable.

However, this symbol is never processed by the symbol resolution handling because it is skipped when looking for symbols in InputFile::Symbol::shouldSkip() - this is because while it is flagged as SF_Global, it is also flagged as SF_FormatSpecific (anything starting with "llvm." is in ModuleSymbolTable::getSymbolFlags (this is not new logic, although it was moved here recently). (Changing the InputFile to not skip this causes issues because the linker doesn't know the semantics of this special appending variable and complains about dup symbols.)

It seems like we need to add anything referenced from at least some of these "FormatSpecific" values as they are potential roots in the dead symbol analysis. The best way I can think of off the top of my head is to write a special InputFile symbol walker that finds these, then somehow cache them so we can tell LTO about them (the symbols are walked in gold when we first look at each file to see if we want to claim it, whereas LTO is not constructed until the linker has analyzed all symbols).


https://reviews.llvm.org/D23488





More information about the llvm-commits mailing list