This is an archive of the discontinued LLVM Phabricator instance.

[Clang][OpenMP] Enable device-mapped constexpr class members to not be optimized out
ClosedPublic

Authored by doru1004 on Mar 21 2023, 11:16 AM.

Details

Summary

This patch fixes an issue whereby a constexpr class member which is mapped to the device is being optimized out thus leading to a runtime error:

Libomptarget error: Unable to generate entries table for device id 0.
Libomptarget error: Failed to init globals on device 0

This is due to the optimized-out variable not being present when host entry table values are matched with their device counterparts.

A currently failing example is included in the runtime test included in this patch.

Diff Detail

Event Timeline

doru1004 created this revision.Mar 21 2023, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2023, 11:16 AM
doru1004 requested review of this revision.Mar 21 2023, 11:16 AM

We should have a clang test as well

We should have a clang test as well

Agreed, working on one currently.

doru1004 updated this revision to Diff 507114.Mar 21 2023, 1:57 PM
jdoerfert added inline comments.Mar 21 2023, 4:23 PM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
10394

I really think we need a different solution to this than the "ref" variables... alas, not with this patch

doru1004 updated this revision to Diff 507190.Mar 21 2023, 6:11 PM
jdoerfert accepted this revision.Mar 21 2023, 8:24 PM

This is as good as it gets until we rip out $ref.

This revision is now accepted and ready to land.Mar 21 2023, 8:24 PM
doru1004 updated this revision to Diff 507483.Mar 22 2023, 1:20 PM

Updated lit test to show variable added to compiler used vars.

doru1004 updated this revision to Diff 507485.Mar 22 2023, 1:23 PM
jhuber6 accepted this revision.Mar 22 2023, 2:32 PM

LG, thanks.

If you include Fixes: <bug url> in the commit message it'll automatically close it by the way.