[clang] 4b85800 - [OpenCL] Set external linkage for block enqueue kernels
Sven van Haastregt via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 12 05:30:48 PST 2022
Author: Sven van Haastregt
Date: 2022-01-12T13:30:09Z
New Revision: 4b85800bfd6ca6c3ecedf68ffbba6c3f2bc9c8ae
URL: https://github.com/llvm/llvm-project/commit/4b85800bfd6ca6c3ecedf68ffbba6c3f2bc9c8ae
DIFF: https://github.com/llvm/llvm-project/commit/4b85800bfd6ca6c3ecedf68ffbba6c3f2bc9c8ae.diff
LOG: [OpenCL] Set external linkage for block enqueue kernels
All kernels can be called from the host as per the SPIR_KERNEL calling
convention. As such, all kernels should have external linkage, but
block enqueue kernels were created with internal linkage.
Reported-by: Pedro Olsen Ferreira
Differential Revision: https://reviews.llvm.org/D115523
Added:
Modified:
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 2bb68ebbfa2a4..77203aee9b6c1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -11417,7 +11417,7 @@ TargetCodeGenInfo::createEnqueuedBlockKernel(CodeGenFunction &CGF,
auto &C = CGF.getLLVMContext();
std::string Name = Invoke->getName().str() + "_kernel";
auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);
- auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, Name,
+ auto *F = llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, Name,
&CGF.CGM.getModule());
auto IP = CGF.Builder.saveIP();
auto *BB = llvm::BasicBlock::Create(C, "entry", F);
diff --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
index afae12f7d25aa..361aca85e84c9 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -402,28 +402,28 @@ kernel void device_side_enqueue(global int *a, global int *b, int i) {
size = get_kernel_sub_group_count_for_ndrange(ndrange, ^(){});
}
-// COMMON: define internal spir_kernel void [[INVLK1]](i8 addrspace(4)* %0) #{{[0-9]+}} {
+// COMMON: define spir_kernel void [[INVLK1]](i8 addrspace(4)* %0) #{{[0-9]+}} {
// COMMON: entry:
// COMMON: call spir_func void @__device_side_enqueue_block_invoke(i8 addrspace(4)* %0)
// COMMON: ret void
// COMMON: }
-// COMMON: define internal spir_kernel void [[INVLK2]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK1]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK2]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK3]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK4]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK5]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK6]](i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) #{{[0-9]+}} {
+// COMMON: define spir_kernel void [[INVLK2]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK1]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK2]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK3]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK4]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK5]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK6]](i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) #{{[0-9]+}} {
// COMMON: entry:
// COMMON: call spir_func void @__device_side_enqueue_block_invoke_9(i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3)
// COMMON: ret void
// COMMON: }
-// COMMON: define internal spir_kernel void [[INVGK7]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK7]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
// COMMON: define internal spir_func void [[INVG8]](i8 addrspace(4)*{{.*}})
// COMMON: define internal spir_func void [[INVG9]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)* %{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK8]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INV_G_K]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVLK3]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK9]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK10]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK11]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK8]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INV_G_K]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVLK3]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK9]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK10]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK11]](i8 addrspace(4)*{{.*}})
More information about the cfe-commits
mailing list