This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add check for constraints on event-stmts
ClosedPublic

Authored by ktras on Nov 1 2022, 3:18 PM.

Details

Summary

In the CoarrayChecker, add checks for the constraints C1177 and
C1178 for event-wait-stmt. Add event-post-stmt to the check
for the constraints for sync-stat-list. Add a check for the
constraint C1176 on event-variable.

Diff Detail

Event Timeline

ktras created this revision.Nov 1 2022, 3:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 3:18 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
ktras requested review of this revision.Nov 1 2022, 3:18 PM

Things generally look good, and everything builds and tests correctly. But if there's no problem moving the query functions to the Semantics directory, we should do that.

flang/include/flang/Evaluate/tools.h
1204–1205

Is Evaluate/tools.h the right place for these functions?

Note that the function IsOrContainsEventOrLockComponent() is in Semantics/tools.h. It also looks like all references to these functions come from within the Semantics directory. Putting them all in the same files and directory makes more sense to me.

ktras added inline comments.Nov 7 2022, 4:14 PM
flang/include/flang/Evaluate/tools.h
1204–1205

Thanks for the feedback. I put these new functions in Evaluate/tools.h since IsTeamType and IsEventTypeOrLockType are both there. I don't have a strong feeling where they should go, but if I move the new functions, then I think those other functions should probably also be moved. What do you think?

PeteSteinfeld accepted this revision.Nov 8 2022, 6:36 AM
PeteSteinfeld added inline comments.
flang/include/flang/Evaluate/tools.h
1204–1205

Gee, IsTeamType is referenced in Evaluate/intrinsics.cpp, so it can't be moved even though it's logically related to the other functions. But IsEventTypeOrLockType is only referenced from the Semantics directory. For locality of reference, it make sense to me to move them.

This revision is now accepted and ready to land.Nov 8 2022, 6:36 AM
ktras added inline comments.Nov 8 2022, 10:24 AM
flang/include/flang/Evaluate/tools.h
1204–1205

What you said about IsTeamType reminded me, I will need to call IsEventType from Evaluate/intrinsics.cpp as well when I add event_query to the list of intrinsic subroutines. I will not need to call IsLockType from that file. What would you think in that case? Still move IsEventType, IsLockType, and IsEventTypeOrLockType? Or just the last two that don't/won't have references in the Evaluate directory?

@klausler It looks like you originally wrote IsEventTypeOrLockType and IsTeamType, do you have an opinion on this?

ktras added a comment.May 15 2023, 9:29 AM

Unfortunately, I let this patch sitting for a while, but I would like to push this soon. @PeteSteinfeld, thank you for the review and for the acceptance of the patch. Previously, I replied to your comment about moving IsEventType and IsLockType and stating that because of future planned changes to support event_query, it seems to me that these new functions should remain where they are now in this patch. Please let me know if you disagree, otherwise I plan to push this differential within the next couple days based on the revision having been accepted. Let me know if you would like me to hold off for further discussion, thanks.

Unfortunately, I let this patch sitting for a while, but I would like to push this soon. @PeteSteinfeld, thank you for the review and for the acceptance of the patch. Previously, I replied to your comment about moving IsEventType and IsLockType and stating that because of future planned changes to support event_query, it seems to me that these new functions should remain where they are now in this patch. Please let me know if you disagree, otherwise I plan to push this differential within the next couple days based on the revision having been accepted. Let me know if you would like me to hold off for further discussion, thanks.

Thanks, @ktras. It's OK with me to leave them where they are.

This revision was automatically updated to reflect the committed changes.
ktras added a comment.May 15 2023, 7:06 PM

Thanks for the review, @PeteSteinfeld.

@ktras, this change is causing some of our internal tests to fail. Here's a small test case that illustrates the problem. This test should compile without error, but it gets a semantic error saying:

bug.f90:4:17: error: The event-variable must be a coarray
      event post (x[1])

Here's the source of the test:

subroutine bug
  use iso_fortran_env
  type(event_type), save :: x[*]
    event post (x[1])
end
ktras added a comment.May 17 2023, 1:21 PM

@PeteSteinfeld, thanks for letting me know. You are right that the event-variable in an event-post-stmt is allowed to be a coindexed-object. It seems like the using the function evaluate::IsCoarray, as I did, to make sure that event-variable is a coarray disallows coindexed-objects. I will make some changes and open a new differential to address this.

@PeteSteinfeld, thanks for letting me know. You are right that the event-variable in an event-post-stmt is allowed to be a coindexed-object. It seems like the using the function evaluate::IsCoarray, as I did, to make sure that event-variable is a coarray disallows coindexed-objects. I will make some changes and open a new differential to address this.

Thanks, @ktras! You're the best.