[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
Fri Oct 27 16:33:57 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:
> `for (auto &GA : SrcM->aliases())` is not tested. Add some tests?
This is covered in `Linker/comdat-any.ll`, case 3.
https://github.com/llvm/llvm-project/pull/69143
More information about the llvm-commits
mailing list