This is an archive of the discontinued LLVM Phabricator instance.

[Clang][OpenMP] Warn and discard write to host for const variable
Changes PlannedPublic

Authored by jplehr on Nov 8 2022, 8:39 AM.

Details

Summary

Resolves a potential segmentation fault in target offload when a constant
variable is mapped as tofrom to the device but placed into constant
memory on the host.

Sema checks if targets of map from: or tofrom: are const-qualified and
warns.
CodeGen changes the map to to: for such variables to remove the write
back to host.
OpenMP Clarification: https://github.com/OpenMP/spec/issues/2158

Diff Detail

Event Timeline

jplehr created this revision.Nov 8 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 8:39 AM
jplehr requested review of this revision.Nov 8 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhuber6 accepted this revision.Nov 14 2022, 9:21 AM

LGTM, others feel free to comment.

This revision is now accepted and ready to land.Nov 14 2022, 9:21 AM
jplehr planned changes to this revision.Dec 12 2022, 6:55 AM

We had another clarifying example on the github issue, which currently is not correctly covered by this patch. I'm currently reworking.