[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Tue Mar 25 02:42:26 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>)
----------------
kiranchandramohan wrote:
Would it also work the other way, and will you use `fir.convert` to convert from volatile to non-volatile? Would it make sense to add a `fir.volatile_cast` operation to add or remove volatile?
Separately, for the general design, is it sufficient to have new operations `fir.volatile_load` and `fir.volatile_store` for accessing volatile memory and not worry about modelling volatile in the type system?
https://github.com/llvm/llvm-project/pull/132486
More information about the flang-commits
mailing list