================
@@ -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
----------------
MattPD wrote:

The six `CHECK-LABEL` directives spell HLFIR symbol names, but `-emit-llvm` 
emits external names. Running this file's own RUN lines fails at the first 
label, and this is the only failing test among the `-finit-local=` set.

The compiler emits `@test_volatile_derived_`, `@test_volatile_real10_`, and 
`@test_volatile_array_`.

The sibling tests match external names portably. `finit-local-array-llvm.f90`, 
`finit-local-real10-llvm.f90`, and `finit-local-logical-llvm.f90` all use 
`define {{.*}}@{{.*}}test_name{{.*}}(`. I changed only the six labels to that 
form, and both RUN lines then passed.


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