This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lowering passing variables to OPTIONAL VALUE
ClosedPublic

Authored by clementval on Jun 23 2022, 3:05 AM.

Details

Summary

The case where the dummy argument is OPTIONAL was missing in the
handling of VALUE numerical and logical dummies (passBy::BaseAddressValueAttribute).
This caused segfaults while unconditionally copying actual arguments that were legally
absent at runtime.

Takes this bug as an opportunity to share the code that lowers arguments
that must be passed by BaseAddress, BaseAddressValueAttribute, BoxChar,
and CharBoxValueAttribute.
It has to deal with the exact same issues (being able to make contiguous
copies of the actual argument, potentially conditionally at runtime,
and potentially requiring a copy-back).
The VALUE case is the same as the non value case, except there is never
a copy-back and there is always a copy-in for variables. This two
differences are easily controlled by a byValue flag.

This as the benefit of implementing CHARACTER, VALUE for free that was
previously a hard TODO.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

clementval created this revision.Jun 23 2022, 3:05 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 23 2022, 3:05 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Jun 23 2022, 3:05 AM

LG.

Are there further patches in the area of optional arguments and strings?

https://github.com/llvm/llvm-project/issues/56139 fails with llvm/flang/main but passes with fir-dev.

This revision is now accepted and ready to land.Jun 23 2022, 3:22 AM
This revision was automatically updated to reflect the committed changes.

Are there further patches in the area of optional arguments and strings?

https://github.com/llvm/llvm-project/issues/56139 fails with llvm/flang/main but passes with fir-dev.

There might be some others but I don't have a clear view of what is left in lowering yet. I'm going by diffs and I would know better early next week.