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

Bruno Cardoso Lopes via All-commits all-commits at lists.llvm.org
Thu Feb 12 21:23:07 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da9c513c87b2fbd32e32e4122dec9ce437f0b9b6
      https://github.com/llvm/llvm-project/commit/da9c513c87b2fbd32e32e4122dec9ce437f0b9b6
  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 (#179828)

This implements the lowering of static local variables with the Itanium C++ ABI
guard variable pattern in LoweringPrepare. This is initial support, errorNYI covering all that hasn't been added just yet.

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

Once the new design doc lands I'll add more information over there.



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