This is an archive of the discontinued LLVM Phabricator instance.

[flang] Create a temporary of the correct size when lowering SetLength in genarr
ClosedPublic

Authored by clementval on Aug 29 2022, 9:46 AM.

Details

Summary

This patch creates a temporary of the appropriate length while lowering SetLength.

The corresponding character can be truncated or padded if necessary.

This fix issue with array constructor in argument and also with statement function.

D132464 was fixing the same issue in genval.

Diff Detail

Event Timeline

clementval created this revision.Aug 29 2022, 9:46 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 29 2022, 9:46 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Aug 29 2022, 9:46 AM
clementval retitled this revision from [flang] Create a temporary of the correct size when lowering SetLengtin genarr to [flang] Create a temporary of the correct size when lowering SetLength in genarr.Aug 29 2022, 10:46 AM
jeanPerier added inline comments.Aug 30 2022, 1:30 AM
flang/lib/Lower/ConvertExpr.cpp
5488

I think the temp should be allocated outside of the lambda so that the allocation happens outside of the loops (otherwise, if the allocation is not hoisted, this may cause an overkill usage of the stack if the array is big).

Create the temp outside of the lambda

jeanPerier accepted this revision.Aug 30 2022, 3:07 AM

LGTM, thanks

This revision is now accepted and ready to land.Aug 30 2022, 3:07 AM