This is an archive of the discontinued LLVM Phabricator instance.

[Flang] [OpenMP] [Semantics] Add missing semantic check for MAP clause.
ClosedPublic

Authored by raghavendhra on Aug 24 2023, 8:11 PM.

Details

Summary

Added support for following semantic check for MAP clause.

  • A list item cannot appear in both a map clause and a data-sharing attribute clause on the same target construct.

Diff Detail

Event Timeline

raghavendhra created this revision.Aug 24 2023, 8:11 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
raghavendhra requested review of this revision.Aug 24 2023, 8:11 PM

Rebasing the patch

NimishMishra added inline comments.Aug 28 2023, 12:28 AM
flang/lib/Semantics/resolve-directives.cpp
532

Question: are we sure that the default ompFlag value should be OmpMapToFrom? Because I see a re-assignment in case Type::Tofrom:.

556

Redundant break? Rather, if the OmpMapType cannot be anything other than the 6 types listed here, then is this a redundant default that can be removed?

569

Question: Is this information used somewhere? As far as I understand, the semantic check resides in checkExclusivelists.

1955

Is this cast necessary for the function call? OmpFlagToClauseName function can also reside as a function in OmpAttributeVisitor imo. It doesn't seem like this function is providing anything specific to the class Symbol. Is it necessary to make this function encapsulated in the Symbol class?

Thanks for your review comments Nimish!

flang/lib/Semantics/resolve-directives.cpp
532

map-type is optional and will take a default value of tofrom

As per the OpenMP 5.1 standard (Pg 353 Line # 2)

  • If a map-type is not specified, the map-type defaults to tofrom.

So, Line 531 is used for no map-type modifier present case.

556

Sure, I will remove this in my next patch.

569

You are correct, this code snippet is used to set appropriate ompFlag related to MAP clause which will be used in checkExclusiveLists to compare against PRIVATE and FIRSTPRIVATE lists

1955

The major reason I defined in Symbol is because all the OmpFlags are defined in Symbol class. I can give a try to move it to OmpAttributeVisitor if needed.

NimishMishra accepted this revision.Aug 28 2023, 7:48 AM

LGTM, with a couple of nits (noted below). Please wait for some more time in case anyone has any comments.

flang/lib/Semantics/resolve-directives.cpp
556

Sure thanks!

1955

That is ok. The OmpFlags can reside in Symbol class. The conversion to clause name can be shifted to OmpAttributeVisitor. Maybe we can take a second opinion on this.

This revision is now accepted and ready to land.Aug 28 2023, 7:48 AM

Please make sure that there are testcases for all the checks that have checkExclusiveLists.

Not approving because I am not super familiar with this part of the code, but LGTM.

flang/lib/Semantics/resolve-directives.cpp
556

Small nit - instead of removing it, maybe put an assert(false) here. If for some reason the code goes here (like introduction of another flag in the future) it should error out.

Addressed review comments. Changed MAP clause semantic check to run through permutation and
combination of different MAP types and data sharing attribute clauses on
checkExclusiveLists(). Rebased the patch.

Rebasing patch

This revision was landed with ongoing or failed builds.Sep 7 2023, 1:42 PM
This revision was automatically updated to reflect the committed changes.

Looks like this patch triggers a new failure https://lab.llvm.org/buildbot/#/builders/175/builds/35729

Thanks for catching this Valentin. Sorry about this build failure and it has been fixed now with https://github.com/llvm/llvm-project/commit/872aa457ba90a90d2005293eebf1775b76a78b59