[clang] 57a210e - [CUDA][HIP] Fix linkage of __clang_gpu_used_external
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 26 17:43:55 PDT 2022
Author: Yaxun (Sam) Liu
Date: 2022-04-26T20:43:39-04:00
New Revision: 57a210e5b705f4d176facbd8a15aa3e89ea9e335
URL: https://github.com/llvm/llvm-project/commit/57a210e5b705f4d176facbd8a15aa3e89ea9e335
DIFF: https://github.com/llvm/llvm-project/commit/57a210e5b705f4d176facbd8a15aa3e89ea9e335.diff
LOG: [CUDA][HIP] Fix linkage of __clang_gpu_used_external
Different TU's may have this globl var. appending linkage can
only be used with lld recognized special variables.
Change it to internal linkage.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D124466
Added:
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/host-used-extern.cu
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 784f2d0e578fa..83f650cb8161d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -598,7 +598,7 @@ void CodeGenModule::Release() {
llvm::ArrayType *ATy = llvm::ArrayType::get(Int8PtrTy, UsedArray.size());
auto *GV = new llvm::GlobalVariable(
- getModule(), ATy, false, llvm::GlobalValue::AppendingLinkage,
+ getModule(), ATy, false, llvm::GlobalValue::InternalLinkage,
llvm::ConstantArray::get(ATy, UsedArray), "__clang_gpu_used_external");
addCompilerUsedGlobal(GV);
}
diff --git a/clang/test/CodeGenCUDA/host-used-extern.cu b/clang/test/CodeGenCUDA/host-used-extern.cu
index f430111b566a2..c7edabf5c582b 100644
--- a/clang/test/CodeGenCUDA/host-used-extern.cu
+++ b/clang/test/CodeGenCUDA/host-used-extern.cu
@@ -11,7 +11,7 @@
#include "Inputs/cuda.h"
-// CHECK-LABEL: @__clang_gpu_used_external = appending {{.*}}global
+// CHECK-LABEL: @__clang_gpu_used_external = internal {{.*}}global
// CHECK-DAG: @_Z7kernel1v
// CHECK-DAG: @_Z7kernel4v
// CHECK-DAG: @var1
More information about the cfe-commits
mailing list