This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add type to firstprivate symbol for const firstprivate values
ClosedPublic

Authored by jhuber6 on Jun 9 2021, 4:40 PM.

Details

Summary

Clang will create a global value put in constant memory if an aggregate value
is declared firstprivate in the target device. The symbol name only uses the
name of the firstprivate variable, so symbol name conflicts will occur if the
variable is allowed to have different types through templates. An example of
this behvaiour is shown in https://godbolt.org/z/EsMjYh47n. This patch adds the
mangled type name to the symbol to avoid such naming conflicts. This fixes
https://bugs.llvm.org/show_bug.cgi?id=50642.

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 9 2021, 4:40 PM
jhuber6 requested review of this revision.Jun 9 2021, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2021, 4:40 PM
jdoerfert added inline comments.Jun 9 2021, 5:01 PM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
10598

What if the code is not C++?

jhuber6 added inline comments.Jun 9 2021, 5:07 PM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
10598

Should work fine, this just mangles it according to the C++ ABI but doesn't require it being C++ as far as I know. Testing it with a sample C file creates the same symbol name as the C++ version.

jhuber6 updated this revision to Diff 351012.Jun 9 2021, 5:27 PM

Changing to only mangle when using C++. It should be correct either way but is unnecessary with C.

This revision is now accepted and ready to land.Jun 10 2021, 5:29 AM