[flang-commits] [flang] [flang][MLIR][OpenMP] Extend delayed privatization for allocatables (PR #84033)

via flang-commits flang-commits at lists.llvm.org
Thu Mar 7 03:03:45 PST 2024


jeanPerier wrote:

For the purpose of OpenMP private cloning and copying, it always safe to use #0 even for assume-shape. Is that correct?

Yes, that is correct. Any usage of "#1" should be seen as optimizations to improve codegeneration at the FIR level. It is always correct to start with "#0".

> And I thought that the `call` operation will use `#1` from the `hlfir.declare` operation that declares `x`. I though so since this is the original SSA value without the `shift` (i.e. without the lower bound). 

The original value is not a fir.box in that case, so what I wrote cannot apply: one cannot save the creation of a descriptor and use `#1`: it is not a descriptor. What I was referring to only apply when the hlfir.declare input is a descriptor.

Anyway, what I wrote above turns out to be incorrect since https://github.com/llvm/llvm-project/commit/de2be3e469f6174871d522ab6950d41282c58c7b that I missed and renders the usages of `#1` in lowering "useless" when it is a box. I will need to analyze this commit. The drawback of this commit is that without inlining, LLVM will not be able to remove the temporary descriptors created to hold lower bounds in pure forwarding cases like below, while the temporary descriptor created to hold local bounds is useless from a Fortran point of view and the input could have been forwarded:

```
subroutine foo(x)
  interface
    subroutine bar(x)
      character(*) :: x(:)
    end subroutine
  end interface
  character(*) :: x(:)
  call bar(x)
end subroutine
```




https://github.com/llvm/llvm-project/pull/84033


More information about the flang-commits mailing list