[llvm-dev] ThinLTO and linkonce_odr + unnamed_addr

Rafael Avila de Espindola via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 15 16:16:31 PST 2018


Steven Wu <stevenwu at apple.com> writes:

> I did a bit more digging for the auto hide problem. Here is my finding that prevent us from doing this by default in GlobalOpts
>
> 1. When a symbol is linkonce_odr hidden unnamed_addr, it emits both '.private_extern' and '.weak_def_can_be_hidden' asm directives on macho platform. There result of that is .private_extern will win so this is essentially linkonce_odr hidden.

What do those directives mean? I assume .weak_def_can_be_hidden is the
"you can drop this from the symbol table", but .private_extern I am not
sure.

> 2. ld64 does treat these two type of symbols differently. For example, ld64 will deduplicate all the can_be_hidden symbols to reduce code size. This can't be achieved when the symbols is private external.

If I understand you correctly, ld64 will deduplicate
std::vector<int>::push_back and std::vector<unsigned>::push_back, but it
will not deduplicate std::vector<HiddenClassA>::push_back and
std::vector<HiddenClassB>::push_back. Is that correct? Do you know why
it has that limitation?

Thanks,
Rafael


More information about the llvm-dev mailing list