This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Add semantic check for threadprivate directive
ClosedPublic

Authored by peixin on Sep 13 2021, 6:22 AM.

Details

Summary

This patch implements the following check for THREADPRIVATE construct:

A variable that is part of another variable (as an array, structure
element or type parameter inquiry) cannot appear in a threadprivate
directive.

Diff Detail

Event Timeline

peixin created this revision.Sep 13 2021, 6:22 AM
peixin requested review of this revision.Sep 13 2021, 6:22 AM

LGTM. I have some Nit comments. Please fix it if possible.

What about the other checks?

flang/lib/Semantics/check-omp-structure.cpp
1555–1563

Nit: Would having a lambda be a better option? The lambda can take the clause or directive as an argument.

1556

Nit: an THREADPRIVATE -> a THREADPRIVATE

This revision is now accepted and ready to land.Sep 13 2021, 7:57 AM
peixin updated this revision to Diff 372386.Sep 13 2021, 7:23 PM

LGTM. I have some Nit comments. Please fix it if possible.

What about the other checks?

I am studying on them and they will come later. I prefer to separate semantic checks with different styles in multiple PRs to make review work easier, but I will keep similar semantic checks in one PR so that the code will not revised again and again.

flang/lib/Semantics/check-omp-structure.cpp
1555–1563

Thanks for the advice. This kind of semantic check is only performed on allocate directive, threadprivate directive, declare target directive, private or shared clause. I replace the comparison check with OmpDirectiveSet currently and do not change the description of PRIVATE or SHARED into dynamic clause name, which is not necessary for current OpenMP 5.1 standard. I agree with you that lambda would be better if more clauses have this restriction.

1556

Fixed.

@kiranchandramohan Does this patch need more review or is it ok to land?

Thanks. Please go ahead and submit.