[PATCH] D43361: [ThinLTO] Enable AutoHide on symbols with local_unnamed_addr

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 15 18:01:52 PDT 2018


espindola added a comment.

> Actually, how does ELF/COFF linker know that if LTO decides to drop local_unnamed_addr (since only macho has flags to indicate that)? Is lld/gold looking at the object file to figure out if there are uses for the addr for this symbol?

Right now the symbol is only  dropped if it is used only from IR files. Any use from ELF counts as cannot be hidden. This is indeed the simple case as the symbol can be internalized.

But it does point out that we have an implicit assumption: no pass drops local_unnamed_addr.

If we had a strange_pass that did that, what we would get is

- Linker gets true for every call to canBeOmittedFromSymbolTable.
- Linker sets VisibleToRegularObj to false for every file.
- LLVM internalizes the GV
- strange_pass adds a use of the address of GV
- we now have an address dependency that can fail.

I am tempered to just document in the language reference that it is invalid for a pass to drop local_unnamed_addr. With that the linker job is even simpler, it doesn't need to check the LTO produced files, just canBeOmittedFromSymbolTable in very IR symbol table.

Peter, what do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D43361





More information about the llvm-commits mailing list