This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Evaluate actual args before impure elemental calls.
ClosedPublic

Authored by vzakhari on Jun 30 2023, 2:26 PM.

Details

Summary

Actual argument expressions must be evaluated before the invocation
of the sequence of per-element calls of an impure elemental subprogram.
Otherwise, the side effects of the calls may affect the input for
the consequent elements.
The proposed changes are described by Jean in D154174.

Diff Detail

Event Timeline

vzakhari created this revision.Jun 30 2023, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 2:26 PM
vzakhari requested review of this revision.Jun 30 2023, 2:26 PM
tblah accepted this revision.Jul 3 2023, 3:25 AM

Thanks for this, LGTM

flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
172

Nit: if I understand correctly, the hlfir.associate should be operating on VAL_5 (the elemental expr), not on a new value.

This revision is now accepted and ready to land.Jul 3 2023, 3:25 AM
vzakhari added inline comments.Jul 3 2023, 9:04 AM
flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
172

You are right. Thanks for the catch! I will fix it before merging.