[llvm] [IR] Avoid collecting COMDATs for non-module printing (PR #221460)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 11:50:19 PDT 2026
================
@@ -3243,13 +3235,14 @@ void AssemblyWriter::printModule(const Module *M) {
printTypeIdentities();
- // Output all comdats.
- if (!Comdats.empty())
+ // Output each used comdat at its first global object.
+ SmallPtrSet<const Comdat *, 8> PrintedComdats;
+ for (const GlobalObject &GO : M->global_objects()) {
+ const Comdat *C = GO.getComdat();
+ if (!C || !PrintedComdats.insert(C).second)
+ continue;
Out << '\n';
- for (const Comdat *C : Comdats) {
printComdat(C);
- if (C != Comdats.back())
- Out << '\n';
}
----------------
aengelke wrote:
Wrap in nested block to free set early.
https://github.com/llvm/llvm-project/pull/221460
More information about the llvm-commits
mailing list