[all-commits] [llvm/llvm-project] 6e4984: [flang][hlfir] Enable assignments with allocatable...
Slava Zakharin via All-commits
all-commits at lists.llvm.org
Tue Jun 6 20:25:29 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6e4984a9d5f34f68f29779b07fff580639bd2f73
https://github.com/llvm/llvm-project/commit/6e4984a9d5f34f68f29779b07fff580639bd2f73
Author: Slava Zakharin <szakharin at nvidia.com>
Date: 2023-06-06 (Tue, 06 Jun 2023)
Changed paths:
M flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
M flang/runtime/assign.cpp
M flang/test/HLFIR/assign-codegen.fir
Log Message:
-----------
[flang][hlfir] Enable assignments with allocatable components.
The TODO was left there to verify that Assign() runtime handles
overlaps of allocatable components. It did not, and this change-set
fixes it. Note that the same Assign() issue can be reproduced
without HLFIR. In the following example the LHS would be reallocated
before value of RHS (essentially, the same memory) is read:
```
program main
type t1
integer, allocatable :: a(:)
end type t1
type(t1) :: x, y
allocate(x%a(10))
do i =1,10
x%a(i) = 2*i
end do
x = x
print *, x%a
deallocate(x%a)
end program main
```
The test's output would be incorrect (though, this depends on the memory
reuse by malloc):
0 0 0 0 10 12 14 16 18 20
It is very hard to add a Flang unittest exploiting derived types.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D152306
More information about the All-commits
mailing list