[all-commits] [llvm/llvm-project] 1324b3: [CIR][LoweringPrepare] Emit guard variables for st...

Bruno Cardoso Lopes via All-commits all-commits at lists.llvm.org
Thu Feb 12 20:05:11 PST 2026


  Branch: refs/heads/users/bcardosolopes/cir-static-local-lowprep
  Home:   https://github.com/llvm/llvm-project
  Commit: 1324b35c85d9d4cc5425fa6eda7183e0cdb2a30b
      https://github.com/llvm/llvm-project/commit/1324b35c85d9d4cc5425fa6eda7183e0cdb2a30b
  Author: Bruno Cardoso Lopes <bruno.cardoso at gmail.com>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
    M clang/include/clang/CIR/Dialect/IR/CIROps.td
    M clang/include/clang/CIR/Interfaces/ASTAttrInterfaces.h
    M clang/include/clang/CIR/Interfaces/ASTAttrInterfaces.td
    M clang/include/clang/CIR/MissingFeatures.h
    M clang/lib/CIR/CodeGen/CIRGenDeclCXX.cpp
    M clang/lib/CIR/CodeGen/CIRGenModule.cpp
    M clang/lib/CIR/Dialect/IR/CIRDialect.cpp
    M clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
    M clang/test/CIR/CodeGen/static-local.cpp
    M clang/test/CIR/IR/invalid-static-local.cir
    M clang/test/CIR/IR/static-local.cir

  Log Message:
  -----------
  [CIR][LoweringPrepare] Emit guard variables for static local initialization

This implements the lowering of static local variables with the Itanium C++ ABI
guard variable pattern in LoweringPrepare.

When a GlobalOp has the static_local attribute and a ctor region, this pass:
1. Creates a guard variable global (mangled name from AST)
2. Inserts the guard check pattern at each GetGlobalOp use site:
   - Load guard byte with acquire ordering
   - If zero, call __cxa_guard_acquire
   - If acquire returns non-zero, inline the ctor region code
   - Call __cxa_guard_release
3. Clears the static_local attribute and ctor region from the GlobalOp



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list