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

Kunal Dubey via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 13:55:32 PDT 2026


================
@@ -104,19 +99,18 @@ void CIRGenModule::emitCXXGlobalVarDeclInitFunc(const VarDecl *vd,
                                                 bool performInit) {
   assert(!cir::MissingFeatures::cudaSupport());
 
-  assert(!cir::MissingFeatures::deferredCXXGlobalInit());
-
-  // TODO(cir): Classic codegen calls emitCXXGuardedInit in the following case:
-  // template<typename T> struct Templ {
-  //   static T f;
-  // };
-  // template<typename T> T Templ<T>::f = get_i();
-  // auto func() {
-  //   Templ<int> t;
-  //   return decltype(t)::f;
-  // }
-  //
-  // However, at the moment it is only suitable for static-local variables, so
-  // we will have to modify it to work for this case as well.
-  emitCXXGlobalVarDeclInit(vd, addr, performInit);
+  // Classic CodeGen dispatches guarded initialization through
+  // CGCXXABI::EmitGuardedInit, which the Microsoft ABI overrides with a
+  // completely different (bitmask-based "magic statics") guard scheme
+  // instead of the Itanium __cxa_guard_acquire/__cxa_guard_release calls
+  // that emitCXXGuardedInit/LoweringPrepare unconditionally assume here.
+  assert(!cir::MissingFeatures::msabi());
----------------
xakep8 wrote:

Ah that makes sense!

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


More information about the cfe-commits mailing list