diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-08-17 17:47:31 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-08-17 17:47:31 +0000 |
commit | 94ff57f5b182e7978dce94d83310ecfac2445abb (patch) | |
tree | 61d55fe5c955a053cb55d815575982a727611e77 | |
parent | 2784a339abc5537326a15613bd2de40a577d5ccf (diff) | |
download | bcm5719-llvm-94ff57f5b182e7978dce94d83310ecfac2445abb.tar.gz bcm5719-llvm-94ff57f5b182e7978dce94d83310ecfac2445abb.zip |
[HIP] Make __hip_gpubin_handle hidden to avoid being merged across different shared libraries
Different shared libraries contain different fat binary, which is stored in a global variable
__hip_gpubin_handle. Since different compilation units share the same fat binary, this
variable has linkonce linkage. However, it should not be merged across different shared
libraries.
This patch set the visibility of the global variable to be hidden, which will make it invisible
in the shared library, therefore preventing it from being merged.
Differential Revision: https://reviews.llvm.org/D50596
llvm-svn: 340056
-rw-r--r-- | clang/lib/CodeGen/CGCUDANV.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCUDA/device-stub.cu | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index 5fcc9e011bc..3f3f2c5e43c 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -459,6 +459,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() { /*Initializer=*/llvm::ConstantPointerNull::get(VoidPtrPtrTy), "__hip_gpubin_handle"); GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getQuantity()); + // Prevent the weak symbol in different shared libraries being merged. + GpuBinaryHandle->setVisibility(llvm::GlobalValue::HiddenVisibility); Address GpuBinaryAddr( GpuBinaryHandle, CharUnits::fromQuantity(GpuBinaryHandle->getAlignment())); diff --git a/clang/test/CodeGenCUDA/device-stub.cu b/clang/test/CodeGenCUDA/device-stub.cu index 716381b7a82..06877da8588 100644 --- a/clang/test/CodeGenCUDA/device-stub.cu +++ b/clang/test/CodeGenCUDA/device-stub.cu @@ -80,7 +80,7 @@ void use_pointers() { // HIP-SAME: section ".hipFatBinSegment" // * variable to save GPU binary handle after initialization // CUDANORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null -// HIP: @__[[PREFIX]]_gpubin_handle = linkonce global i8** null +// HIP: @__[[PREFIX]]_gpubin_handle = linkonce hidden global i8** null // * constant unnamed string with NVModuleID // RDC: [[MODULE_ID_GLOBAL:@.*]] = private constant // CUDARDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32 |