[all-commits] [llvm/llvm-project] 32c26e: CUDA/HIP: Use kernel name to map to symbol
Daniele Castagna via All-commits
all-commits at lists.llvm.org
Thu Jan 19 15:02:33 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 32c26e27b6fcd12703dcd00adf178330d0ad8449
https://github.com/llvm/llvm-project/commit/32c26e27b6fcd12703dcd00adf178330d0ad8449
Author: Daniele Castagna <dcastagna at rivosinc.com>
Date: 2023-01-19 (Thu, 19 Jan 2023)
Changed paths:
M clang/lib/CodeGen/CGCUDANV.cpp
A clang/test/CodeGenCUDA/incomplete-func-ptr-type.cu
Log Message:
-----------
CUDA/HIP: Use kernel name to map to symbol
Currently CGCUDANV uses an llvm::Function as a key to map kernels to a
symbol in host code. HIP adds one level of indirection and uses the
llvm::Function to map to a global variable that will be initialized to
the kernel stub ptr.
Unfortunately there is no garantee that the llvm::Function created
by GetOrCreateLLVMFunction will be the same. In fact, the first
time we encounter GetOrCrateLLVMFunction for a kernel, the type
might not be completed yet, and the type of llvm::Function will be
a generic {}, since the complete type is not required to get a symbol
to a function. In this case we end up creating two global variables,
one for the llvm::Function with the incomplete type and one for the
function with the complete type. The first global variable will be
declared by not defined, resulting in a linking error.
This change uses the mangled name of the llvm::Function as key in the
KernelHandles map, in this way the same llvm::Function will be
associated to the same kernel handle even if they types are different.
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D140663
More information about the All-commits
mailing list