[PATCH] D97930: [OpenCL] Fix builtins that require multiple extensions
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 5 09:13:14 PST 2021
svenvh updated this revision to Diff 328549.
svenvh added a comment.
> You don't seem to be using write_imagef for OpenCL versions <= 1.2. But should we be checking that the diagnostic is given?
Good point, I have updated the test to check for the diagnostic.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97930/new/
https://reviews.llvm.org/D97930
Files:
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===================================================================
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,10 @@
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
+#endif
+
// First, test that Clang gracefully handles missing types.
#ifdef NO_HEADER
void test_without_header() {
@@ -169,13 +173,20 @@
}
#endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
-kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer) {
+kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer, write_only image3d_t image3dwo) {
half4 h4;
float4 f4;
int i;
write_imagef(image_write_only_image1d_buffer, i, f4);
write_imageh(image_write_only_image1d_buffer, i, h4);
+
+ int4 i4;
+ write_imagef(image3dwo, i4, i, f4);
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+ // expected-error at -2{{no matching function for call to 'write_imagef'}}
+ // expected-note at -3 + {{candidate function not viable}}
+#endif
}
kernel void basic_subgroup(global uint *out) {
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -815,9 +815,20 @@
// Ignore this builtin function if it carries an extension macro that is
// not defined. This indicates that the extension is not supported by the
// target, so the builtin function should not be available.
- StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension];
- if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext))
- continue;
+ StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension];
+ if (!Extensions.empty()) {
+ SmallVector<StringRef, 2> ExtVec;
+ Extensions.split(ExtVec, " ");
+ bool AllExtensionsDefined = true;
+ for (StringRef Ext : ExtVec) {
+ if (!S.getPreprocessor().isMacroDefined(Ext)) {
+ AllExtensionsDefined = false;
+ break;
+ }
+ }
+ if (!AllExtensionsDefined)
+ continue;
+ }
SmallVector<QualType, 1> RetTypes;
SmallVector<SmallVector<QualType, 1>, 5> ArgTypes;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97930.328549.patch
Type: text/x-patch
Size: 2447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210305/1fe9699a/attachment-0001.bin>
More information about the cfe-commits
mailing list