You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version of flang-new : 17.0.0(f6c4808d95221a5838e14474d95c6fe85bb1488a)
AArch64
An assignment statement using an array as an array index in the FORALL construct results in a segmentation fault.
Changing the array index from v (i) to i, as shown below, result in successful compilation.
Before the change
forall (i =1: 5)
v (i) = i
b (v (i): v (i)) = mod 01 _ fun1 (a (v (i): v (i)))
end forall
After the change
forall (i =1: 5)
b (i: i) = mod01 _ fun1 (a (i: i))
end forall
The following are the test program, results of Flang-new, GFortran and ifort compilation and execution.
snf95_120_2.f90:
program main
call test01()
print*,'pass'end program main
module mod01
containselementalfunctionmod01_fun1(i) result(ifun)
intent(in) :: i
ifun=i
endfunction mod01_fun1end module mod01
subroutinetest01()
use mod01
integer v(5),a(5),b(5)
a=reshape((/(i,i=1,5)/),(/5/))
b=0write(6,*) "a = ", a
forall (i=1:5)
v(i)=i
b(v(i):v(i))=mod01_fun1(a(v(i):v(i)))
end forallwrite(6,*) "b = ", b
if (any(a.ne.b)) write(6,*) "NG"endsubroutine test01
Elemental procedures may need their array arguments to be passed by
address. This is done by setting ArrayExprLowering::semant to a
value that corresponds to this semantics. Later, member functions
such as applyPathToArrayLoad() read this variable to generate FIR
instructions that match the needed behavior. The problem is that
the semant variable also affects how array paths are lowered. Thus,
if an index of the path is an array element, this will cause its
address to be used instead of its value, which usually results in a
segmentation fault at runtime.
Example: b(i:i) = elem_func(a(v(i):v(i)))
To fix this, ArrayExprLowering::nextPathSemant was added. When it's
set, the next array path is handled with the semantics specified by
it, while the elemental argument retains its original semantics.
Fixesllvm/llvm-project#62981
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D153454
An assignment statement using an array as an array index in the
FORALL
construct results in a segmentation fault.Changing the array index from v (i) to i, as shown below, result in successful compilation.
The following are the test program, results of Flang-new, GFortran and ifort compilation and execution.
snf95_120_2.f90
:The text was updated successfully, but these errors were encountered: