[lld] [ELF] Respect ltoCanOmit for symbols in non-prevailing COMDAT (PR #119332)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 10:01:01 PST 2024
https://github.com/smithp35 commented:
I found this quite difficult to review, although I think that's down to ELF and bitcode having subtle differences. It may have helped to review https://github.com/llvm/llvm-project/commit/c6508809585505ffb88f5f724da04bbc058eabf8 as that has some related changes.
Just to make sure I've understood.
A `weak_odr`, according to https://llvm.org/docs/LangRef.html#linkage-types , may not be discarded. A `linkonce_odr` is permitted to be discarded.
If an ELF group is prevailing then all is well as the ELF group will have all the definitions.
If the weak_odr group prevails then all is well as the symbol is not permitted to be discarded.
If the linkonce_odr group prevails over a weak_odr group then we must in effect make the prevailing definition weak_odr so that LTO does not remove it.
We do this by creating a new definition for all non-prevailing groups, which may clear the `ltoCanOmit` flag. This via `Symbol::includeInDynsym(Ctx &ctx)` communicates to LTO that the symbol is preserved. As these symbols are bitcode symbols in non-prevailing groups they do not generate multiple definition errors.
Assuming I've understood the code changes look good.
https://github.com/llvm/llvm-project/pull/119332
More information about the llvm-commits
mailing list