[flang][hlfir] Fix multiple return declaration type
authorTom Eccles <tom.eccles@arm.com>
Wed, 14 Jun 2023 13:23:00 +0000 (13:23 +0000)
committerTom Eccles <tom.eccles@arm.com>
Mon, 19 Jun 2023 09:09:01 +0000 (09:09 +0000)
commit569716fc5c2c232adcd5ff840637be596c1de9b9
tree5232078fb9420cb311fcbe7188154dc0fb7078c9
parent6826d3c513b3366edb6b8fde769b4c5d90c4be19
[flang][hlfir] Fix multiple return declaration type

When the ENTRY statement is used, the same source can return different
types depending on the entry point. These different return values are
storage associated (share the same storage). Previously, this led to the
declaration of the results to all have the largest type. This patch adds
a convert between the stack allocation and the declaration so that the
hlfir.decl gets the right type.

I haven't managed to generate code where this convert converted a
reference to an allocation for a smaller type into an allocation for a
larger one, but I have added an assert just in case.

This is a different solution to https://reviews.llvm.org/D152725, see
discussion there.

Differential Revision: https://reviews.llvm.org/D152931
flang/lib/Lower/Bridge.cpp
flang/test/Lower/HLFIR/entry_return.f90 [new file with mode: 0644]