[all-commits] [llvm/llvm-project] 243ebf: [hip][cuda] Fix the extended lambda name mangling ...
darkbuck via All-commits
all-commits at lists.llvm.org
Fri Oct 18 17:14:05 PDT 2019
Author: Michael Liao <michael.hliao at gmail.com>
Date: 2019-10-19 (Sat, 19 Oct 2019)
[hip][cuda] Fix the extended lambda name mangling issue.
- HIP/CUDA host side needs to use device kernel symbol name to match the
device side binaries. Without a consistent naming between host- and
device-side compilations, it's risky that wrong device binaries are
executed. Consistent naming is usually not an issue until unnamed
types are used, especially the lambda. In this patch, the consistent
name mangling is addressed for the extended lambdas, i.e. the lambdas
annotated with `__device__`.
- In [Itanium C++ ABI], the mangling of the lambda is generally
unspecified unless, in certain cases, ODR rule is required to ensure
consisent naming cross TUs. The extended lambda is such a case as its
name may be part of a device kernel function, e.g., the extended
lambda is used as a template argument and etc. Thus, we need to force
ODR for extended lambdas as they are referenced in both device- and
host-side TUs. Furthermore, if a extended lambda is nested in other
(extended or not) lambdas, those lambdas are required to follow ODR
naming as well. This patch revises the current lambda mangle numbering
to force ODR from an extended lambda to all its parent lambdas.
- On the other side, the aforementioned ODR naming should not change
those lambdas' original linkages, i.e., we cannot replace the original
`internal` with `linkonce_odr`; otherwise, we may violate ODR in
general. This patch introduces a new field `HasKnownInternalLinkage`
in lambda data to decouple the current linkage calculation based on
mangling number assigned.
Reviewers: tra, rsmith, yaxunl, martong, shafik
Differential Revision: https://reviews.llvm.org/D68818
More information about the All-commits