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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 13:52:19 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());
----------------
erichkeane wrote:

We actually have tests that are hitting stuff here, a NYI isn't really appropriate, the missing-features' purpose is to point out that we don't do microsoft ABI yet.  SO I think this is correct as a MissingFeatures.

I misspoke earlier (actually switched between the two) when I was looking at this, which is why my comment says NYI.

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


More information about the cfe-commits mailing list