[llvm] [Linker] Do not keep a private member of a non-prevailing comdat group (PR #69143)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 18:56:16 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))
----------------
MaskRay wrote:
`for (auto &GA : SrcM->aliases())` is not tested. Add some tests?
https://github.com/llvm/llvm-project/pull/69143
More information about the llvm-commits
mailing list