You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CIR] Implement static local variable initialization with guard variables
This implements thread-safe initialization of function-local static
variables with dynamic initializers, following the Itanium C++ ABI.
The implementation:
1. Adds `static_local` attribute to GlobalOp and GetGlobalOp to mark
function-local statics requiring guarded initialization
2. Implements guarded initialization in LoweringPrepare pass using
__cxa_guard_acquire/__cxa_guard_release for thread safety
3. Adds helper methods createIsNull/createIsNotNull to CIRBaseBuilder
4. Implements emitGuardedInit in CIRGenItaniumCXXABI to emit the
ctor region and mark the global as static_local
5. Adds mangleStaticGuardVariable to ASTAttrInterfaces for mangling
The guard variable pattern follows Itanium ABI 3.3.2:
- First byte of guard checked with acquire load for fast path
- __cxa_guard_acquire called if uninitialized
- __cxa_guard_release called after successful initialization
ghstack-source-id: 29329f1
Pull-Request: #2046
0 commit comments