Skip to content

Commit c08746e

Browse files
authored
Add clang patches to fix Image types related issue (#392)
This is WA for clang the issue llvm/llvm-project#58017 Patches are needed because the proper fixes will be avaiable only for llvm versions greater than LLVM15
1 parent 2867197 commit c08746e

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 9780cc0e044c73dcd549c67a1278a4ff7daf3b01 Mon Sep 17 00:00:00 2001
2+
From: Marcin Naczk <[email protected]>
3+
Date: Fri, 4 Nov 2022 15:41:16 +0100
4+
Subject: [PATCH] Remove wrong check of __opencl_c_images feature macro
5+
6+
Deleted mechanism that wrongly assumes that
7+
all functions that use image types must be under
8+
__opencl_c_images feature macro
9+
Mechanism added by https://reviews.llvm.org/D103911
10+
More info on github issue:
11+
https://github.com/llvm/llvm-project/issues/58017
12+
---
13+
clang/lib/Sema/SemaType.cpp | 8 +-------
14+
1 file changed, 1 insertion(+), 7 deletions(-)
15+
16+
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
17+
index ab47e9f03eaf..f72c2fb57ddd 100644
18+
--- a/clang/lib/Sema/SemaType.cpp
19+
+++ b/clang/lib/Sema/SemaType.cpp
20+
@@ -1741,13 +1741,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
21+
// __opencl_c_3d_image_writes feature. OpenCL C v3.0 API s4.2 - For devices
22+
// that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and
23+
// only when the optional feature is supported
24+
- if ((Result->isImageType() || Result->isSamplerT()) &&
25+
- (IsOpenCLC30Compatible &&
26+
- !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts()))) {
27+
- S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
28+
- << 0 << Result << "__opencl_c_images";
29+
- declarator.setInvalidType();
30+
- } else if (Result->isOCLImage3dWOType() &&
31+
+ if (Result->isOCLImage3dWOType() &&
32+
!OpenCLOptions.isSupported("cl_khr_3d_image_writes",
33+
S.getLangOpts())) {
34+
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
35+
--
36+
2.33.0.windows.1
37+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From bb5e22800857f7dda9a2491a4f2fc7387d4205b0 Mon Sep 17 00:00:00 2001
2+
From: Marcin Naczk <[email protected]>
3+
Date: Fri, 4 Nov 2022 15:45:17 +0100
4+
Subject: [PATCH] Fix checking mechanism for read_write Image type
5+
6+
The commit
7+
https://github.com/llvm/llvm-project/commit/91a0b464a853821734db8b1c521df03f8e2e56e7
8+
Enabled opencl feature macro __opencl_c_read_write_images
9+
by default for the SPIR and SPIR-V targets
10+
therefore the mechanism of checking read_write image type
11+
should take into account if the target is SPIR or SPIR-V
12+
---
13+
clang/lib/Sema/SemaDeclAttr.cpp | 5 +++--
14+
1 file changed, 3 insertions(+), 2 deletions(-)
15+
16+
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
17+
index e76e7c608e0c..2d60d2b03169 100644
18+
--- a/clang/lib/Sema/SemaDeclAttr.cpp
19+
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
20+
@@ -7823,8 +7823,9 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21+
bool ReadWriteImagesUnsupported =
22+
(S.getLangOpts().getOpenCLCompatibleVersion() < 200) ||
23+
(S.getLangOpts().getOpenCLCompatibleVersion() == 300 &&
24+
- !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images",
25+
- S.getLangOpts()));
26+
+ !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", S.getLangOpts()) &&
27+
+ !S.getASTContext().getTargetInfo().getTriple().isSPIR() &&
28+
+ !S.getASTContext().getTargetInfo().getTriple().isSPIRV());
29+
if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
30+
S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write)
31+
<< AL << PDecl->getType() << DeclTy->isImageType();
32+
--
33+
2.33.0.windows.1
34+

0 commit comments

Comments
 (0)