================
@@ -0,0 +1,102 @@
+! 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: derived-type
+! record fill, real(10) allocation-gap fill, integer array element fill,
+! and both the compile-time-length and runtime-length CHARACTER byte loops.
+!
+! 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 {{.*}}@{{.*}}test_volatile_derived{{.*}}(
+! HEX:        store volatile i8
+
+! ZERO-LABEL: define {{.*}}@{{.*}}test_volatile_derived{{.*}}(
+! ZERO:        store volatile i8
+
+! ---------------------------------------------------------------------------
+! Volatile real(10) local -- allocation-gap byte-fill loop.
+! real(10) = x86_fp80: 10-byte store size, 16-byte allocation.
+! ---------------------------------------------------------------------------
+subroutine test_volatile_real10(res)
+  real(10), volatile :: x
+  real(10) :: res
+  res = x
+end subroutine
+
+! HEX-LABEL: define {{.*}}@{{.*}}test_volatile_real10{{.*}}(
+! HEX:        store volatile i8
+
+! ZERO-LABEL: define {{.*}}@{{.*}}test_volatile_real10{{.*}}(
+! ZERO:        store volatile i8
+
+! ---------------------------------------------------------------------------
+! Volatile integer array local -- rank-1 array-view byte-fill loop.
+! ---------------------------------------------------------------------------
+subroutine test_volatile_array(res)
+  integer(4), volatile :: x(4)
+  integer :: res
+  res = x(1)
+end subroutine
+
+! HEX-LABEL: define {{.*}}@{{.*}}test_volatile_array{{.*}}(
+! HEX:        store volatile i32
+
+! ZERO-LABEL: define {{.*}}@{{.*}}test_volatile_array{{.*}}(
+! ZERO:        store volatile i32
+
+! ---------------------------------------------------------------------------
+! Volatile fixed-length CHARACTER local -- compile-time-length byte-fill loop.
+! hex: loop over nLen bytes -> store volatile i8.
+! zero: fir.zero_bits store -> store volatile i8 0.
+! ---------------------------------------------------------------------------
+subroutine test_volatile_char_fixed(res)
+  character(10), volatile :: x
+  character(10) :: res
+  res = x
+end subroutine
+
+! HEX-LABEL: define {{.*}}@{{.*}}test_volatile_char_fixed{{.*}}(
+! HEX:        store volatile i8
+
+! ZERO-LABEL: define {{.*}}@{{.*}}test_volatile_char_fixed{{.*}}(
+! ZERO:        store volatile [10 x i8] zeroinitializer
----------------
MattPD wrote:

Could the commit message that changed this line name the cause rather than the 
symptom? The expectation is stronger now, since it pins the value and the full 
ten-byte width. Only the commit message seems off.

This test is gated `REQUIRES: x86-registered-target` and pinned to `-triple 
x86_64-unknown-linux-gnu`, so its output does not depend on the host. The 
fixed-length CHARACTER zero fill emits one aggregate store. The previous `store 
volatile i8` string could never match that store, so the failure was 
deterministic everywhere the test ran.

"Fix Linux and Windows test failure" also reads as though it addresses the 
Linux and Windows CI failures on this PR. Those come from 
`flang/test/Driver/fveclib.f90`, which this PR does not change.

https://github.com/llvm/llvm-project/pull/216164
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to