[llvm] [Linker] Do not keep a private member of a non-prevailing comdat group (PR #69143)
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 19:00:55 PDT 2023
================
@@ -497,6 +501,23 @@ bool ModuleLinker::run() {
for (Function &GV : llvm::make_early_inc_range(DstM))
dropReplacedComdat(GV, ReplacedDstComdats);
+ if (!NonPrevailingComdats.empty()) {
+ DenseSet<GlobalObject *> AliasedGlobals;
+ for (auto &GA : SrcM->aliases())
+ if (GlobalObject *GO = GA.getAliaseeObject(); GO && GO->getComdat())
+ AliasedGlobals.insert(GO);
+ for (const Comdat *C : NonPrevailingComdats) {
+ SmallVector<GlobalObject *> ToUpdate;
+ for (GlobalObject *GO : C->getUsers())
+ if (GO->hasPrivateLinkage() && !AliasedGlobals.contains(GO))
----------------
igorkudrin wrote:
This change would break the `Linker/comdat-refer-to-discarded.ll` test. Originally, it was `Linker/comdat13.ll` in https://github.com/llvm/llvm-project/commit/baa3bf8f76568de6198613fb2ba7695a76c29109, which stated that the duplication of `internal` globals "matches the expectations of COFF linkers`. Since no high-level example was provided, it is now quite difficult, at least for me, to judge whether that behavior is correct or not, so I would prefer not to change it in my patch.
https://github.com/llvm/llvm-project/pull/69143
More information about the llvm-commits
mailing list