[all-commits] [llvm/llvm-project] 0daa80: [flang][hlfir] Create temporary for passing consta...
Slava Zakharin via All-commits
all-commits at lists.llvm.org
Wed May 24 12:00:34 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0daa80e856152ed3250e2925195098f436531ce9
https://github.com/llvm/llvm-project/commit/0daa80e856152ed3250e2925195098f436531ce9
Author: Slava Zakharin <szakharin at nvidia.com>
Date: 2023-05-24 (Wed, 24 May 2023)
Changed paths:
M flang/include/flang/Optimizer/Builder/HLFIRTools.h
M flang/include/flang/Optimizer/Dialect/FortranVariableInterface.td
M flang/lib/Lower/ConvertCall.cpp
A flang/test/Lower/HLFIR/calls-constant-expr-arg.f90
Log Message:
-----------
[flang][hlfir] Create temporary for passing constant expression for actual arg.
Even though the constant expression actual argument is not definable,
and the associated dummy argument is not definable, the compiler may produce
implicit copies into the memory storage associated with the constant expression.
For example, a constant expression storage passed by reference to a subprogram
may be used for implicit copy-out:
```
subroutine sub(i, n)
interface
subroutine sub2(i)
integer :: i(*)
end subroutine sub2
end interface
integer :: i(n)
call sub2(i(3::2)) ! copy-out after the call will write to 'i'
end subroutine sub
subroutine test
call sub((/1,2,3,4,5/), 5)
end subroutine test
```
If we pass a reference to constant expression storage to 'sub' directly,
the copy-out inside 'sub' will try to write into readonly memory.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D151271
More information about the All-commits
mailing list