This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP]Fix capturing of global variables in OpenMP regions.
ClosedPublic

Authored by ABataev on Apr 8 2020, 7:19 AM.

Details

Summary

The global variable should be captured in the region only if it was
privitized in the region or in any of the outer regions. Otherwise, it
should not be captured.

Diff Detail

Event Timeline

ABataev created this revision.Apr 8 2020, 7:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2020, 7:19 AM
jdoerfert added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
2127

Does DSAStack->getDefaultDSA() != DSA_none work once we have (first)private default kinds or do we need to check for shared explicitly?

clang/test/OpenMP/parallel_codegen.cpp
55

@fghanim We have to look into this once you merge the privatization patch.

ABataev marked an inline comment as done.Apr 8 2020, 4:13 PM
ABataev added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
2127

An extra check for != DSA_firstprivate will be required.

jdoerfert accepted this revision.Apr 8 2020, 4:49 PM
jdoerfert added a subscriber: atmnpatel.

LGTM.

clang/lib/Sema/SemaOpenMP.cpp
2127

OK. Needs to be part of D75591. @atmnpatel Can you include this in your patch?

This revision is now accepted and ready to land.Apr 8 2020, 4:49 PM
ABataev marked an inline comment as done.Apr 8 2020, 5:46 PM
ABataev added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
2127

Most probably, even this won't be necessary. Either getTopDSA will rerurn OMPC_firstprivate, or the if statement after this one will return false and control fallback to the default return nullptr;

This revision was automatically updated to reflect the committed changes.