This is an archive of the discontinued LLVM Phabricator instance.

Fix runtime problem for base class member data used in target region.
ClosedPublic

Authored by jyu2 on Jan 9 2023, 9:06 PM.

Details

Summary

The problem is happened when base class member field is used in target
region , the size is wrong, cause runtime to fail. Currently the size of
calculation is depended on index of field, since field is in base class,
the calculation is wrong.

According OpenMP 5.2 148:21:
If the target construct is within a class non-static member function,
and a variable is an accessible data member of the object for which the
non-static data member function is invoked, the variable is treated as
if the this[:1] expression had appeared in a map clause with a map-type
of tofrom.

One way to fix this is emitting code to generate this[:1] instead only
when class has any base class.

Diff Detail

Event Timeline

jyu2 created this revision.Jan 9 2023, 9:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 9:06 PM
jyu2 requested review of this revision.Jan 9 2023, 9:06 PM
ye-luo added a subscriber: ye-luo.Jan 9 2023, 9:24 PM

Does this patch work when there are more than one level of inheritance? For example class B: public A; class C: public B

jyu2 added a comment.Jan 9 2023, 9:34 PM

Does this patch work when there are more than one level of inheritance? For example class B: public A; class C: public B

Yes, that works. For that we emit this[:1] instead. I can add more test that.

ABataev added inline comments.Jan 10 2023, 2:49 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
8451

const auto *RD = dyn_cast<CXXRecordDecl>(MD->getParent()). Also, can we use MD->getParent()->getAsCXXRecordDecl()?

8452

MD is true if HasBaseClass is true

jyu2 updated this revision to Diff 487845.Jan 10 2023, 9:36 AM

Thanks Alexey for code review. This is to address his comments.

clang/lib/CodeGen/CGOpenMPRuntime.cpp
8451

Thank! Changed.

8452

Sorry, changed.

This revision is now accepted and ready to land.Jan 10 2023, 9:49 AM
This revision was landed with ongoing or failed builds.Jan 10 2023, 5:14 PM
This revision was automatically updated to reflect the committed changes.