Skip to content

Commit 039b159

Browse files
committed
rework base class behavior
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent da1523e commit 039b159

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,20 @@ TargetCodeGenInfo::getDependentLibraryOption(llvm::StringRef Lib,
104104
}
105105

106106
unsigned TargetCodeGenInfo::getDeviceKernelCallingConv() const {
107-
// Device kernels are called via an explicit runtime API with arguments,
108-
// such as set with clSetKernelArg() for OpenCL, not as normal sub-functions.
109-
// Return SPIR_KERNEL by default as the kernel calling convention to
110-
// ensure the fingerprint is fixed such way that each kernel argument
111-
// gets one matching argument in the produced kernel function argument
112-
// list to enable feasible implementation of clSetKernelArg() with
113-
// aggregates etc. In case we would use the default C calling conv here,
114-
// clSetKernelArg() might break depending on the target-specific
115-
// conventions; different targets might split structs passed as values
116-
// to multiple function arguments etc.
117-
return llvm::CallingConv::SPIR_KERNEL;
107+
if (getABIInfo().getContext().getLangOpts().OpenCL) {
108+
// Device kernels are called via an explicit runtime API with arguments,
109+
// such as set with clSetKernelArg() for OpenCL, not as normal
110+
// sub-functions. Return SPIR_KERNEL by default as the kernel calling
111+
// convention to ensure the fingerprint is fixed such way that each kernel
112+
// argument gets one matching argument in the produced kernel function
113+
// argument list to enable feasible implementation of clSetKernelArg() with
114+
// aggregates etc. In case we would use the default C calling conv here,
115+
// clSetKernelArg() might break depending on the target-specific
116+
// conventions; different targets might split structs passed as values
117+
// to multiple function arguments etc.
118+
return llvm::CallingConv::SPIR_KERNEL;
119+
}
120+
llvm_unreachable("Unknown kernel calling convention");
118121
}
119122

120123
void TargetCodeGenInfo::setOCLKernelStubCallingConvention(

0 commit comments

Comments
 (0)