[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:46:54 PDT 2026
================
@@ -0,0 +1,65 @@
+! LLVM IR-level regression test for volatile byte-fill stores.
+! Verifies that volatile locals produce "store volatile" in LLVM IR for
+! every byte written by the -finit-local= byte-fill paths.
+!
+! At -O2 a non-volatile fill of a volatile variable can be eliminated
+! entirely. These checks confirm the stores carry the volatile flag.
+!
+! REQUIRES: x86-registered-target
+!
+! RUN: %flang_fc1 -emit-llvm -triple x86_64-unknown-linux-gnu \
+! RUN: -finit-local=0xAA %s -o - | FileCheck --check-prefix=HEX %s
+! RUN: %flang_fc1 -emit-llvm -triple x86_64-unknown-linux-gnu \
+! RUN: -finit-local=zero %s -o - | FileCheck --check-prefix=ZERO %s
+
+! ---------------------------------------------------------------------------
+! Volatile derived-type local -- record byte-fill loop.
+! Every store into the record's bytes must be "store volatile i8".
+! ---------------------------------------------------------------------------
+subroutine test_volatile_derived(oa)
+ type :: t
+ integer(4) :: a
+ integer(1) :: b
+ end type
+ type(t), volatile :: v
+ integer :: oa
+ v%a = 1
+ oa = v%a
+end subroutine
+
+! HEX-LABEL: define {{.*}}@_QPtest_volatile_derived
----------------
DanielCChen wrote:
Fixed. All six `CHECK-LABEL` directives now use `define {{.*}}@{{.*}}test_name{{.*}}(` to match external names portably, consistent with `finit-local-array-llvm.f90`, `finit-local-real10-llvm.f90`, and `finit-local-logical-llvm.f90`.
https://github.com/llvm/llvm-project/pull/216164
More information about the flang-commits
mailing list