This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Require trivially copyable type for mapping
ClosedPublic

Authored by Hahnfeld on Dec 6 2019, 10:45 AM.

Details

Summary

A trivially copyable type provides a trivial copy constructor and a trivial
copy assignment operator. This is enough for the runtime to memcpy the data
to the device. Additionally there must be no virtual functions or virtual
base classes and the destructor is guaranteed to be trivial, ie performs
no action.
The runtime does not require trivial default constructors because on alloc
the memory is undefined. Thus, weaken the warning to be only issued if the
mapped type is not trivially copyable.

Diff Detail

Event Timeline

Hahnfeld created this revision.Dec 6 2019, 10:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2019, 10:45 AM
ABataev added inline comments.Dec 6 2019, 10:53 AM
clang/lib/Sema/SemaOpenMP.cpp
14919

Need to add a check for defaulted destructor here, isTriviallyCopyableType does not include this check.

Hahnfeld marked 2 inline comments as done.Dec 6 2019, 12:01 PM
Hahnfeld added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
14919

As I said in the summary, this is a prerequisite for being trivially copyable and as such checked by CXXRecordDecl::isTriviallyCopyable() (line if (!hasTrivialDestructor()) return false;).

This revision is now accepted and ready to land.Dec 6 2019, 12:08 PM
This revision was automatically updated to reflect the committed changes.
Hahnfeld marked an inline comment as done.