[flang] Fix fir.embox codegen with constant interior shape
authorJean Perier <jperier@nvidia.com>
Tue, 5 Apr 2022 15:26:53 +0000 (17:26 +0200)
committerJean Perier <jperier@nvidia.com>
Tue, 5 Apr 2022 15:27:03 +0000 (17:27 +0200)
commit0601a0dc0135fea422e2c794fb392efef8857b3a
tree22c3a2145a9437d91c8e38aa0e3861b32317a1e9
parentbb3afae99b5ba5e865b237913104ca7ab2ed2baa
[flang] Fix fir.embox codegen with constant interior shape

Fix https://github.com/flang-compiler/f18-llvm-project/issues/1416.

The `constRows` variable was being decremented too soon, causing the
last constant interior dimension extent being used to multiply the GEP
offset. This lead to wrong address computation and caused segfaults.

Note: also upstream fir.embox tests that can be upstreamed.

Differential Revision: https://reviews.llvm.org/D123130
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/embox.fir [new file with mode: 0644]