[all-commits] [llvm/llvm-project] 45bc3f: [flang] Add -finit-local= to initialize automatic ...
Daniel Chen via All-commits
all-commits at lists.llvm.org
Wed Sep 23 14:39:39 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 45bc3fbacaed869924160d9c3addc2364d2d4cc0
https://github.com/llvm/llvm-project/commit/45bc3fbacaed869924160d9c3addc2364d2d4cc0
Author: Daniel Chen <cdchen at ca.ibm.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M clang/include/clang/Options/FlangOptions.td
M clang/lib/Driver/ToolChains/Flang.cpp
A flang-rt/test/Driver/finit-local-array-exec.f90
A flang-rt/test/Driver/finit-local-char2-exec.f90
A flang-rt/test/Driver/finit-local-charN-exec.f90
M flang/docs/ReleaseNotes.md
M flang/include/flang/Lower/LoweringOptions.def
M flang/include/flang/Lower/LoweringOptions.h
M flang/lib/Frontend/CompilerInvocation.cpp
M flang/lib/Lower/ConvertVariable.cpp
M flang/lib/Optimizer/Dialect/FIRType.cpp
A flang/test/Driver/finit-local.f90
A flang/test/Lower/CUDA/finit-local-cuda.cuf
A flang/test/Lower/finit-local-array-llvm.f90
A flang/test/Lower/finit-local-cray-pointee.f90
A flang/test/Lower/finit-local-exclusions.f90
A flang/test/Lower/finit-local-f128.f90
A flang/test/Lower/finit-local-kind-mapping-rtchar.f90
A flang/test/Lower/finit-local-kind-mapping-subbyte.f90
A flang/test/Lower/finit-local-kind-mapping.f90
A flang/test/Lower/finit-local-logical-llvm.f90
A flang/test/Lower/finit-local-packed.f90
A flang/test/Lower/finit-local-ppc-vector-llvm.f90
A flang/test/Lower/finit-local-real10-llvm.f90
A flang/test/Lower/finit-local-unsigned.f90
A flang/test/Lower/finit-local-volatile-llvm.f90
A flang/test/Lower/finit-local-volatile-real10.f90
A flang/test/Lower/finit-local-volatile.f90
A flang/test/Lower/finit-local.f90
M flang/tools/bbc/bbc.cpp
Log Message:
-----------
[flang] Add -finit-local= to initialize automatic variables (#216164)
This patch implements the `-finit-local=` compiler option, which
initializes automatic (local) Fortran variables that have no explicit or
default initialization.
Assisted-by: IBM Bob
RFC:
https://discourse.llvm.org/t/rfc-add-finit-local-to-flang-for-initializing-automatic-variables/91545
## Accepted values
| Value | Effect |
|-------|--------|
| `zero` | Fill every storage byte with zero |
| `0x` | Fill every storage byte with the given hex pattern |
The gfortran compatibility alias `-finit-local-zero` is equivalent to
`-finit-local=zero`.
## Excluded variables (not initialized)
- Variables with explicit initializers (`integer :: x = 42`)
- Variables initialized via DATA statement
- Derived-type variables whose type has default component initialization
- SAVE variables (static storage)
- Dummy arguments
- ALLOCATABLE and POINTER variables
- Variables in EQUIVALENCE sets
- Cray pointees (their FIR base is a pointer-box descriptor, not value
storage)
- CUDA variables in device-only memory (`device`, `constant`, `shared`,
`usedevice`)
- **PowerPC vector locals** (`vector(real(4))` etc., direct or as a
derived-type component) — `fir::VectorType` does not implement
`DataLayoutTypeInterface`; see `finit-local-ppc-vector-llvm.f90`
## Known limitations
- CHARACTER arrays are not yet initialized (TODO: PR #159788).
- Arrays with unknown or zero extent at compile time are skipped.
- `REAL(16)`/`COMPLEX(16)` require `flang-supports-f128-math`.
- Sub-byte or non-byte-multiple kind mappings for LOGICAL without
allocation padding emit a controlled TODO diagnostic in hex mode only
(zero mode and padded mappings are supported in both modes).
- PowerPC vector locals are excluded (direct or as a derived-type
component).
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