================
@@ -112,11 +188,119 @@ struct LoweringPreparePass
   llvm::StringMap<uint32_t> dynamicInitializerNames;
   llvm::SmallVector<cir::FuncOp> dynamicInitializers;
 
+  /// Tracks guard variables for static locals.
+  llvm::DenseMap<const clang::VarDecl *, cir::GlobalOp> 
staticLocalDeclGuardMap;
+
   /// List of ctors and their priorities to be called before main()
   llvm::SmallVector<std::pair<std::string, uint32_t>, 4> globalCtorList;
   /// List of dtors and their priorities to be called when unloading module.
   llvm::SmallVector<std::pair<std::string, uint32_t>, 4> globalDtorList;
 
+  /// Returns true if the target uses ARM-style guard variables for static
+  /// local initialization (32-bit guard, check bit 0 only).
+  bool useARMGuardVarABI() const {
+    switch (astCtx->getCXXABIKind()) {
+    case clang::TargetCXXABI::GenericARM:
+    case clang::TargetCXXABI::iOS:
+    case clang::TargetCXXABI::WatchOS:
+    case clang::TargetCXXABI::GenericAArch64:
+    case clang::TargetCXXABI::WebAssembly:
+      return true;
+    default:
+      return false;
+    }
+  }
+
+  /// Emit the guarded initialization for a static local variable.
+  /// This handles the if/else structure after the guard byte check,
+  /// following OG's ItaniumCXXABI::EmitGuardedInit skeleton.
+  void emitCXXGuardedInitIf(CIRBaseBuilderTy &builder, cir::GlobalOp globalOp,
----------------
andykaylor wrote:

Shouldn't all this be happening in the CXXABILowering pass?

https://github.com/llvm/llvm-project/pull/179828
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to