This is an archive of the discontinued LLVM Phabricator instance.

[flang] Prevent any non constant result extent to be inlined on caller side
ClosedPublic

Authored by jeanPerier on Jan 19 2022, 8:34 AM.

Details

Summary

UBOUND, SIZE, and SHAPE folding was still creating expressions that are
invalid on the caller side without the call expression context.
A previous patch intended to deal with this situation (https://reviews.llvm.org/D116933)
but it assumed the return expression would be a descriptor inquiry to
the result symbol, which is not the case if the extent expression is
"scope invariant" inside the called subroutine (e.g., referring to
intent(in) dummy arguments). Simply prevent folding from inlining non
constant extent expression on the caller side.

Folding could be later improved by having ad-hoc folding for UBOUND, SIZE, and
SHAPE on function references where it could try replacing the dummy symbols
by the actual expression, but this is left as a possible later improvement.

Diff Detail

Event Timeline

jeanPerier created this revision.Jan 19 2022, 8:34 AM
jeanPerier requested review of this revision.Jan 19 2022, 8:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2022, 8:34 AM
klausler accepted this revision.Jan 19 2022, 9:12 AM
This revision is now accepted and ready to land.Jan 19 2022, 9:12 AM