[clang] [llvm] [OpenMP] Fix convention of SPIRV outline functions (PR #192450)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 06:37:14 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Alex Duran (adurang)
<details>
<summary>Changes</summary>
When creating an outline function for device code we're not setting the right calling convention when the target is SPIRV. This results in the calls to the function to be removed by the InstCombine pass as it thinks is not callable.
---
Full diff: https://github.com/llvm/llvm-project/pull/192450.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+6)
- (modified) offload/test/offloading/ompx_coords.c (-1)
``````````diff
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 59d0e6825a975..01de7a410c38f 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -608,6 +608,12 @@ static llvm::Function *emitOutlinedFunctionPrologue(
llvm::Function::Create(FuncLLVMTy, llvm::GlobalValue::InternalLinkage,
FO.FunctionName, &CGM.getModule());
CGM.SetInternalFunctionAttributes(CD, F, FuncInfo);
+
+ // Adjust the calling convention for SPIR-V targets to avoid mismatches
+ // between callee and caller.
+ if (CGM.getTriple().isSPIRV() && !FO.IsDeviceKernel)
+ F->setCallingConv(llvm::CallingConv::SPIR_FUNC);
+
if (CD->isNothrow())
F->setDoesNotThrow();
F->setDoesNotRecurse();
diff --git a/offload/test/offloading/ompx_coords.c b/offload/test/offloading/ompx_coords.c
index 71979ef2ebe87..7cca784a90905 100644
--- a/offload/test/offloading/ompx_coords.c
+++ b/offload/test/offloading/ompx_coords.c
@@ -1,7 +1,6 @@
// RUN: %libomptarget-compileopt-run-and-check-generic
//
// REQUIRES: gpu
-// XFAIL: intelgpu
#include <omp.h>
#include <ompx.h>
``````````
</details>
https://github.com/llvm/llvm-project/pull/192450
More information about the cfe-commits
mailing list