This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Fix one bug in parsing depend(sink: vec)
AbandonedPublic

Authored by peixin on Aug 22 2021, 7:16 PM.

Details

Summary

This patch fixes one bug of no symbol found in parsing depend(sink: vec)
by replacing "Name" with "OmpObject". The "vec" in "depend(sink: vec)"
is one list of experssion of "OmpObject [Operator ScalarIntConstant]"
such as "i, j - 1".

Diff Detail

Event Timeline

peixin created this revision.Aug 22 2021, 7:16 PM
peixin requested review of this revision.Aug 22 2021, 7:16 PM
kiranchandramohan requested changes to this revision.Aug 24 2021, 4:36 AM
kiranchandramohan added inline comments.
flang/include/flang/Parser/parse-tree.h
3439

In a dependence vector, the names correspond to the iteration variables of loops. While OmpObject can represent variables, it can also represent other things like array expressions, common-blocks etc. Without additional semantics checks this might not be correct, isn't it?

This revision now requires changes to proceed.Aug 24 2021, 4:36 AM
peixin added a comment.EditedAug 24 2021, 6:35 AM

@kiranchandramohan Thanks for pointing out the problem. I think you are right.
I guess the problem is that the name resolution has not been finished. I tried the following change and the command ninja check-flang works fine.

diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 071a668de7fd..ff0a38117a73 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -46,6 +46,7 @@ public:
 
   // Name resolution yet implemented:
   // TODO: Can some/all of these now be enabled?
+  bool Pre(parser::Name &) { return false; }
   bool Pre(parser::EquivalenceStmt &) { return false; }
   bool Pre(parser::Keyword &) { return false; }
   bool Pre(parser::EntryStmt &) { return false; }

In addition, the following code can pass the frontend compilation and the name "j" is dumped in parser tree. I am not sure if this check should be implemented in the name resolution or semantic check.

!$omp do ordered(1)
do i = 2, N
  !$omp ordered depend(sink: j - 1)
  B(i) = bar(A(i), B(i-1))
end do
| | | | | | | Name = 'j'
| | | | | | | OmpDependSinkVecLength
| | | | | | | | DefinedOperator -> IntrinsicOperator = Subtract
| | | | | | | | Scalar -> Integer -> Constant -> Expr = '1_4'
| | | | | | | | | LiteralConstant -> IntLiteralConstant = '1'

Is it ok to use this fix and leave "TODO" here for temporary fix? I need this for lowering depend(sink: vec). Or can I post the question of the name resolution on slack and let someone who knows the implementation of the name resolution fix it?

I think resolving the name in flang/lib/Semantics/resolve-directives.cpp is better since some semantic checks can be done at the same time. I will use the method in D94087. This PR may can be closed.

@peixin can you close this review?

peixin abandoned this revision.Sep 2 2021, 5:55 AM