[CUDA][HIP] Fix mangling number for local struct
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Wed, 30 Mar 2022 14:33:03 +0000 (10:33 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Thu, 28 Apr 2022 23:54:43 +0000 (19:54 -0400)
commit11d3e31c60bdc9e491c51b97a964b6289575edfa
treee3a00cfb7a49399734b71544622bc13863ae8182
parent981ed72a17e4302dfd77ac54d742c08dfb6b35bb
[CUDA][HIP] Fix mangling number for local struct

MSVC and Itanium mangling use different mangling numbers
for function-scope structs, which causes inconsistent
mangled kernel names in device and host compilations.

This patch uses Itanium mangling number for structs
in for mangling device side names in CUDA/HIP host
compilation on Windows to fix this issue.

A state is added to ASTContext to indicate whether the
current name mangling is for device side names in host
compilation. Device and host mangling number
are encoded/decoded as upper and lower half of 32 bit
unsigned integer to fit into the original mangling number
field for AST. Diagnostic will be emitted if a manglining
number exceeds limit.

Reviewed by: Artem Belevich, Reid Kleckner

Differential Revision: https://reviews.llvm.org/D122734

Fixes: SWDEV-328515
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/MicrosoftCXXABI.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/test/CodeGenCUDA/struct-mangling-number.cu [new file with mode: 0644]