[flang] Fix AllocaOp/AllocMemOp type conversion
authorPeixinQiao <qiaopeixin@huawei.com>
Fri, 6 May 2022 14:10:13 +0000 (22:10 +0800)
committerPeixinQiao <qiaopeixin@huawei.com>
Fri, 6 May 2022 14:10:13 +0000 (22:10 +0800)
commitac0f4c8f362e819316ca152315e930f4e6515e9d
treeaa070da0dc6f860c5d9fcda572bf9508382dfd9f
parent0863abe3ac47c281fdd35dc87d83c495cf741da0
[flang] Fix AllocaOp/AllocMemOp type conversion

For arrays without a constant interior or arrays of character with
dynamic length arrays, the data types are converted to a pointer to the
element type, so the scale size of the constant extents needs to be
counted. The previous AllocaOp conversion does not consider the arrays
of character with dynamic length arrays, and the previous AllocMemOp
conversion does not consider arrays without a constant interior. This
fixes them and refactors the code so that it can be shared. Also add
the test cases.

Reviewed By: Jean Perier

Differential Revision: https://reviews.llvm.org/D124766
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/alloc.fir
flang/test/Fir/convert-to-llvm.fir