[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)
Asher Mancinelli via flang-commits
flang-commits at lists.llvm.org
Mon Mar 24 11:24:31 PDT 2025
================
@@ -0,0 +1,21 @@
+// RUN: fir-opt --convert-hlfir-to-fir %s -o - | FileCheck %s
+func.func @foo() {
+ %true = arith.constant true
+ %false = arith.constant false
+ %0 = fir.alloca !fir.logical<4> {bindc_name = "a", uniq_name = "_QFEa"}
+ %1 = fir.convert %0 : (!fir.ref<!fir.logical<4>>) -> !fir.ref<!fir.logical<4>, volatile>
+ %2:2 = hlfir.declare %1 {fortran_attrs = #fir.var_attrs<volatile>, uniq_name = "_QFEa"} : (!fir.ref<!fir.logical<4>, volatile>) -> (!fir.ref<!fir.logical<4>, volatile>, !fir.ref<!fir.logical<4>, volatile>)
----------------
ashermancinelli wrote:
I'm not sure yet, but I did discuss this with Jean. He brought up this example: if a variable is only declared volatile in a subroutine, the alloca should not return a volatile ref though the ref should be volatile within the scope of the subroutine ([example on godbolt](https://godbolt.org/z/8Ka8Y8s83)). We should be able to drop the volatile attribute though.
https://github.com/llvm/llvm-project/pull/132486
More information about the flang-commits
mailing list