[PATCH] D92735: [Flang] [OpenMP] Add semantic checks for invalid branch into/from OpenMP constructs

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 24 08:13:32 PST 2021


kiranchandramohan requested changes to this revision.
kiranchandramohan added a comment.
This revision now requires changes to proceed.

In D92735#2514762 <https://reviews.llvm.org/D92735#2514762>, @praveen wrote:

> @kiranchandramohan @sameeranjoshi
>
> I tried to make use of the **CheckBranchesIntoDoBody** function, but since it involves the use of multiple functions and types defined in //resolve-labels.cpp// such as using //**ProxyForScope**//, **//LabeledStatementInfoTuplePOD//**, //**SourceStatementInfoTuplePOD**// and also the labels, scopes and other details are being identified as part of the walk in //ParseTreeAnalyzer// class, it would be more complex to reuse these functions.
>
> Hence I felt adding the logic in resolve-directives.cpp to identify the control flow to / from OpenMP structured blocks would be simple .

OK if it is difficult or too specialized for Do loops then no need to reuse CheckBranchesIntoDoBody.

> Also handled the checks for all the statements involving labels as in 'LabelEnforce' class except //AssignStmt//.
>
> void LabelEnforce::Post(const parser::AssignStmt &);
> The check involving AssignStmt in LabelEnforce may not be suitable as part of the control flow checks for OpenMP constructs.
>
>   integer :: b
>   !$omp parallel
>   assign 5 to b
>   !$omp end parallel
>   
>   5 print *, 5
>
> In the above example, we detect this as an error as part of the 'LabelEnforce' check.
>
> Can we make use of the function **CheckLabelContext** added as part of this change itself to check the control flow escaping the OpenMP constructs ?

Can we remove void LabelEnforce::Post(const parser::AssignStmt &); from LabelEnforce? Are you saying it is not applicable in this context but applicable in other contexts?

You might want to do a thorough check to ensure that the branch into checks are called for all OpenMP constructs. I think it is now not called at least for Critical, Ordered constructs.



================
Comment at: flang/test/Semantics/omp-invalid-branch.f90:11
+  !$omp parallel
+  !ERROR: Control flow escapes from PARALLEL
+  open (10, file="myfile.dat", err=100)
----------------
Why doesn't the other error (invalid branches to/from OpenMP structured blocks) show here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92735/new/

https://reviews.llvm.org/D92735



More information about the llvm-commits mailing list