This can raise problems when internalised symbol is in comdat, while another member of comdat is exported. Such case is handled by internalize pass which is invoked later.
I think this change is generally good but sorry I am not quite familiar with the semantics of comdat. Can you explain in more detail why that can be a problem to internalize that in promote?
Comdats have a name which represents the COMDAT key. All global objects that specify this key will only end up in the final object file if the linker chooses that key over some other key
To enforce this LLVM internalize pass doesn't internalize entire COMDAT group if any of its members should be preserved (see shouldPreserveGV). At the moment we can internalize global
in llvm::thinLTOResolvePrevailingInModule without looking at other COMDAT group members and break this guarantee
Yep, just had a chance to look. Suggest adding a comment above the new check that internalization is done separately since the internalization code contains the necessary correctness checks.