[clang] [CIR] Fix 'vague' linkage globals. (PR #228586)

Kunal Dubey via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 23:00:42 PDT 2026


================
@@ -215,6 +221,10 @@ struct LoweringPreparePass
                                     cir::IntType guardTy,
                                     cir::GlobalLinkageKind linkage);
 
+  /// Append 'global' to the module's llvm.used list to make sure it doesn't get
+  /// garbage-collected by the linker.
+  void addUsedGlobal(cir::GlobalOp global);
+
----------------
xakep8 wrote:

One last thing I just found:

Classic CodeGen also puts the generated initializer function into the variable’s COMDAT, we should do the same no?

https://github.com/llvm/llvm-project/blob/0f9eb78ecd819a7929891f15c447aa6ba8ed522c/clang/lib/CodeGen/CGDeclCXX.cpp#L647

https://github.com/llvm/llvm-project/pull/228586


More information about the cfe-commits mailing list