[flang-commits] [clang] [flang] [llvm] [flang] Add -finit-local= to initialize automatic variables (PR #216164)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Thu Sep 3 04:52:43 PDT 2026


================
@@ -0,0 +1,92 @@
+! Pinned negative tests for -finit-local= exclusions.
+!
+! Each case uses %flang_fc1 -emit-hlfir -finit-local=0xAA and asserts that
+! no synthesized initialization store appears for the excluded variable.
+!
+! Exclusions verified here:
+!   1. Function result variable
+!   2. Main-program local (implicit SAVE per Fortran 2018 8.5.16p4)
+!   3. Runtime-sized automatic array (unknown extent at compile time)
+!   4. CHARACTER array (pending memset infrastructure, PR #159788)
+!   5. Derived type with POINTER component (IsAllocatableOrPointer on component)
+!   6. host,device CUDA local (allocated via cuf.alloc, not fir.alloca)
+!      -- see finit-local-cuda.cuf for the CUDA cases
+!   7. PowerPC vector locals (direct or as a derived-type component)
+!      -- see finit-local-ppc-vector-llvm.f90 for the vector cases
+
+! RUN: %flang_fc1 -emit-hlfir -finit-local=0xAA %s -o - | FileCheck %s
----------------
DanielCChen wrote:

Added `integer :: ctrl` (declared before `x`) to cases 3, 4, and 5. `CHECK: arith.constant {{.*}} : i32` after `ctrl`'s declare confirms the option is active. `CHECK-NOT: fir.store` after `x`'s declare catches a direct synthesized store; the existing `CHECK-NOT: fir.do_loop` catches a byte-fill loop.

https://github.com/llvm/llvm-project/pull/216164


More information about the flang-commits mailing list