When assigning one scalar result to array section in forall construct
and the scalar result is generated with some temporary memory, the free
operation cannot be done after lowering the rhs expression since the
free operation will be outside the fir.do_loop region and the argument
of the free operation is illegal. Move the explicit space finalization
to lowerArrayExpression(rhs) when the rhs has scalar result.
Details
Diff Detail
Event Timeline
flang/lib/Lower/ConvertExpr.cpp | ||
---|---|---|
3371 | Testing the rank all over the place doesn't seem correct. Expressions can contain subexpressions with or without rank and build temporaries accordingly. Finalization should really happen unconditionally. (In the right place, of course.) |
flang/lib/Lower/ConvertExpr.cpp | ||
---|---|---|
3371 |
integer :: arr(6), i forall (i=1:6:2) arr(i:i+1) = (/(func(j),j=i,i+1)/) end forall print *, arr contains pure function func(a) result(res) integer, intent(in) :: a integer :: res res = a end function end Are you pointing to this?
If so, the solution would be better than this patch. If you already how to do it, can you take up this? This kind of solution is beyond my current knowledge of FIR lowering. Sorry about this. |
flang/lib/Lower/ConvertExpr.cpp | ||
---|---|---|
3371 | Sure. Let me take a closer look here. |
Testing the rank all over the place doesn't seem correct. Expressions can contain subexpressions with or without rank and build temporaries accordingly.
Finalization should really happen unconditionally. (In the right place, of course.)