[flang][fir] Redundant DeclareOps for assumed rank arrays.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Consider the following fortran code.
```
program main
implicit none
integer :: d0,d1(3),d2(3,3),d3(3,3,3)
d0 = 5
d1 = 6
d2 = 7
d3 = 8
print *, mean(d0)
print *, mean(d1)
print *, mean(d2)
print *, mean(d3)
contains
function mean(x) result(y)
integer, intent(in) :: x(..)
integer :: y
select rank(x)
rank(0) ; y = 0
rank(1) ; y = rank(x)
rank(2) ; y = rank(x)
rank(3) ; y = rank(x)
rank default ; y = 100
end select
end function mean
end program main
```
generate the fir using the following command
`flang -fc1 -emit-mlir test.f90 -mmlir -mlir-print-debuginfo -debug-info-kind=standalone -O0`
You will notice that it has around 6 `declare.op` for variable `x` which is an assumed rank array. We end up generating multiple entries for this in the debug information which is not only waste of space but also confuses the debugger.
Contributor guide
Assessment
This issue has not been assessed yet.