[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)

Asher Mancinelli via flang-commits flang-commits at lists.llvm.org
Tue Mar 25 13:37:46 PDT 2025


ashermancinelli wrote:

For Assign in particular, I think we can use `fir::factory::genScalarAssignment` to get volatile loads/stores instead of doing it in the runtime at all. I'm still going through the other runtime routines.

Another thought: the only time casts between volatile and non-volatile types should automatically happen is at callsites. IIUC, if a variable is volatile in the caller's scope but not in the callee scope (or any other time there's a mismatch between argument types and the function declaration's types), then we should automatically add conversions. 
```
program p
integer,volatile::v
v=0
! casting from volatile ref to non-volatile ref should be okay here
call not_declared_volatile_in_this_scope(v)
print*,v
contains
subroutine not_declared_volatile_in_this_scope(v)
integer::v
v=1
end subroutine
end program
```
Kiran's suggestion of using a special cast op separate from `fir.convert` seems good to me - `fir.convert` can check that it's not adding or dropping volatility.

https://github.com/llvm/llvm-project/pull/132486


More information about the flang-commits mailing list