mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
[Clang] Prevent mlink-builtin-bitcode from internalizing the RPC client (#118661)
Summary: Currently, we only use `-mlink-builtin-bitcode` for non-LTO NVIDIA compiliations. This has the problem that it will internalize the RPC client symbol which needs to be visible to the host. To counteract that, I put `retain` on it, but this also prevents optimizations on the global itself, so the passes we have that remove the symbol don't work on OpenMP anymore. This patch does the dumbest solution, adding a special string check for it in clang. Not the best solution, the runner up would be to have a clang attribute for `externally_initialized` because those can't be internalized, but that might have some unfortunate side-effects. Alternatively we could make NVIDIA compilations do LTO all the time, but that would affect some users and it's harder than I thought.
This commit is contained in:
@@ -233,6 +233,10 @@ bool InternalizePass::internalizeModule(Module &M) {
|
||||
else
|
||||
AlwaysPreserved.insert("__stack_chk_guard");
|
||||
|
||||
// Preserve the RPC interface for GPU host callbacks when internalizing.
|
||||
if (Triple(M.getTargetTriple()).isNVPTX())
|
||||
AlwaysPreserved.insert("__llvm_rpc_server");
|
||||
|
||||
// Mark all functions not in the api as internal.
|
||||
IsWasm = Triple(M.getTargetTriple()).isOSBinFormatWasm();
|
||||
for (Function &I : M) {
|
||||
|
||||
@@ -105,14 +105,8 @@ void *indirectCallLookup(void *HstPtr) {
|
||||
}
|
||||
|
||||
/// The openmp client instance used to communicate with the server.
|
||||
/// FIXME: This is marked as 'retain' so that it is not removed via
|
||||
/// `-mlink-builtin-bitcode`
|
||||
#ifdef __NVPTX__
|
||||
[[gnu::visibility("protected"), gnu::weak,
|
||||
gnu::retain]] rpc::Client Client asm("__llvm_rpc_client");
|
||||
#else
|
||||
[[gnu::visibility("protected"), gnu::weak]] rpc::Client Client asm("__llvm_rpc_client");
|
||||
#endif
|
||||
[[gnu::visibility("protected"),
|
||||
gnu::weak]] rpc::Client Client asm("__llvm_rpc_client");
|
||||
|
||||
} // namespace impl
|
||||
} // namespace ompx
|
||||
|
||||
Reference in New Issue
Block a user