Author: Alex Duran
Date: 2026-05-08T12:26:39Z
New Revision: 39dc4b0f32dd898a41f9e51fa182f4021b983699

URL: 
https://github.com/llvm/llvm-project/commit/39dc4b0f32dd898a41f9e51fa182f4021b983699
DIFF: 
https://github.com/llvm/llvm-project/commit/39dc4b0f32dd898a41f9e51fa182f4021b983699.diff

LOG: [clang][OpenMP][SPIRV] Use the right calling convention for reduction 
helpers (#195911)

This is a follow-up to #194879 to ensure that the helpers for reduction use the 
right calling convention (in particular that they are marked as spir_func for 
SPIRV).

Assisted by Claude Sonnet 4.5.

Added: 
    

Modified: 
    clang/test/OpenMP/spirv_target_teams_reduction_addrspace.c
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/OpenMP/spirv_target_teams_reduction_addrspace.c 
b/clang/test/OpenMP/spirv_target_teams_reduction_addrspace.c
index bddd5548b9b8b..7217ef9400a6b 100644
--- a/clang/test/OpenMP/spirv_target_teams_reduction_addrspace.c
+++ b/clang/test/OpenMP/spirv_target_teams_reduction_addrspace.c
@@ -18,8 +18,10 @@
 // Verify __kmpc_free_shared is called.
 // CHECK: call spir_func addrspace(9) void @__kmpc_free_shared(ptr addrspace(4)
 
-// Verify the reduction function is generated.
-// CHECK: define internal void @{{.*}}reduction{{.*}}func
+// Verify the reduction helper functions are generated.
+// CHECK: define internal spir_func void @{{.*}}reduction{{.*}}func
+// CHECK: define internal spir_func void @{{.*}}shuffle_and_reduce_func
+// CHECK: define internal spir_func void @{{.*}}inter_warp_copy_func
 
 int main() {
   int x = 0;

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index e3d5bf0663490..19bfff7a7a4e0 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3430,6 +3430,7 @@ Expected<Function *> 
OpenMPIRBuilder::emitInterWarpCopyFunction(
   Function *WcFunc =
       Function::Create(FuncTy, GlobalVariable::InternalLinkage,
                        "_omp_reduction_inter_warp_copy_func", &M);
+  WcFunc->setCallingConv(Config.getRuntimeCC());
   WcFunc->setAttributes(FuncAttrs);
   WcFunc->addParamAttr(0, Attribute::NoUndef);
   WcFunc->addParamAttr(1, Attribute::NoUndef);
@@ -3690,6 +3691,7 @@ Expected<Function *> 
OpenMPIRBuilder::emitShuffleAndReduceFunction(
   Function *SarFunc =
       Function::Create(FuncTy, GlobalVariable::InternalLinkage,
                        "_omp_reduction_shuffle_and_reduce_func", &M);
+  SarFunc->setCallingConv(Config.getRuntimeCC());
   SarFunc->setAttributes(FuncAttrs);
   SarFunc->addParamAttr(0, Attribute::NoUndef);
   SarFunc->addParamAttr(1, Attribute::NoUndef);
@@ -4386,6 +4388,7 @@ Expected<Function *> 
OpenMPIRBuilder::createReductionFunction(
   std::string Name = getReductionFuncName(ReducerName);
   Function *ReductionFunc =
       Function::Create(FuncTy, GlobalVariable::InternalLinkage, Name, &M);
+  ReductionFunc->setCallingConv(Config.getRuntimeCC());
   ReductionFunc->setAttributes(FuncAttrs);
   ReductionFunc->addParamAttr(0, Attribute::NoUndef);
   ReductionFunc->addParamAttr(1, Attribute::NoUndef);


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to