This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] support dynamically optional array arguments to intrinsics with custom handling
ClosedPublic

Authored by tblah on Jul 14 2023, 7:06 AM.

Details

Summary

The previous code path created the elemental kernel by generating a
scalar intrinsic call using pre-prepared arguments using genIntrinsicRefCore,
which then generated the intrinsic call using genIntrinsicCall().

The problem with this approach was that the dynamically optional
arguments were marked as having no argLowering, which meant that they
were unconditionally passed by value without any check to see if they
were present.

It would be nice to put an if operation in the path for !argLowering,
doing something similar to genOptionalValue(). However, this can't be
done because it isn't clear what value should be used for the default.
If zero was used (like in genOptionalValue) this could effect the result
of MIN or MAX.

Instead, this patch re-uses the implementation for scalar dynamically
optional arguments (in non-elemental calls). This does the correct
thing, entirely ignoring absent optional arguments.

Depends On: D155292

Diff Detail

Event Timeline

tblah created this revision.Jul 14 2023, 7:06 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 14 2023, 7:06 AM
tblah requested review of this revision.Jul 14 2023, 7:06 AM
vzakhari accepted this revision.Jul 14 2023, 10:40 AM
This revision is now accepted and ready to land.Jul 14 2023, 10:40 AM
This revision was landed with ongoing or failed builds.Jul 18 2023, 4:05 AM
This revision was automatically updated to reflect the committed changes.