Skip to content

Commit 35f893b

Browse files
committed
[PATCH][Clang] Fix invalid address space generation for clk_event_t
1 parent 13d8ba8 commit 35f893b

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ set(TARGET_NAME ${COMMON_CLANG_LIBRARY_NAME}${BUILD_PLATFORM} )
8181
if(NOT USE_PREBUILT_LLVM)
8282
set(TARGET_BRANCH "ocl-open-70")
8383
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
84-
set(CLANG_BASE_REVISION e44b4e4240e03c24f5479f81235519493823c27b)
84+
set(CLANG_BASE_REVISION 4519e2637fcc4bf6e3049a0a80e6a5e7b97667cb)
8585

8686
set(SPIRV_SOURCE_DIR ${LLVM_SOURCE_DIR}/projects/llvm-spirv)
8787
set(SPIRV_BASE_REVISION 4d62009e2225024abd481ca982ec3d63304df3f0)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From c7ee1afbc6399023296cddeab2b53ed55a123de4 Mon Sep 17 00:00:00 2001
2+
From: Alexey Sotkin <[email protected]>
3+
Date: Wed, 14 Nov 2018 09:40:05 +0000
4+
Subject: [PATCH] [OpenCL] Fix invalid address space generation for clk_event_t
5+
6+
Summary:
7+
Addrspace(32) was generated when putting 0 in clk_event_t * event_ret
8+
parameter for enqueue_kernel function.
9+
10+
Patch by Viktoria Maksimova
11+
12+
Reviewers: Anastasia, yaxunl, AlexeySotkin
13+
14+
Reviewed By: Anastasia, AlexeySotkin
15+
16+
Subscribers: cfe-commits
17+
18+
Differential Revision: https://reviews.llvm.org/D53809
19+
20+
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346838 91177308-0d34-0410-b5e6-96231b3b80d8
21+
---
22+
lib/CodeGen/CGBuiltin.cpp | 4 +++-
23+
test/CodeGenOpenCL/cl20-device-side-enqueue.cl | 9 ++++++++-
24+
2 files changed, 11 insertions(+), 2 deletions(-)
25+
26+
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
27+
index 0770c20..cd074af 100644
28+
--- a/lib/CodeGen/CGBuiltin.cpp
29+
+++ b/lib/CodeGen/CGBuiltin.cpp
30+
@@ -3400,7 +3400,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
31+
llvm::Value *ClkEvent = EmitScalarExpr(E->getArg(5));
32+
// Convert to generic address space.
33+
EventList = Builder.CreatePointerCast(EventList, EventPtrTy);
34+
- ClkEvent = Builder.CreatePointerCast(ClkEvent, EventPtrTy);
35+
+ ClkEvent = ClkEvent->getType()->isIntegerTy()
36+
+ ? Builder.CreateBitOrPointerCast(ClkEvent, EventPtrTy)
37+
+ : Builder.CreatePointerCast(ClkEvent, EventPtrTy);
38+
auto Info =
39+
CGM.getOpenCLRuntime().emitOpenCLEnqueuedBlock(*this, E->getArg(6));
40+
llvm::Value *Kernel =
41+
diff --git a/test/CodeGenOpenCL/cl20-device-side-enqueue.cl b/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
42+
index d74a1df..120a426 100644
43+
--- a/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
44+
+++ b/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
45+
@@ -79,6 +79,13 @@ kernel void device_side_enqueue(global int *a, global int *b, int i) {
46+
a[i] = b[i];
47+
});
48+
49+
+ // COMMON-LABEL: call i32 @__enqueue_kernel_basic_events
50+
+ // COMMON-SAME: (%opencl.queue_t{{.*}}* {{%[0-9]+}}, i32 {{%[0-9]+}}, %struct.ndrange_t* {{.*}}, i32 1, %opencl.clk_event_t{{.*}}* addrspace(4)* {{%[0-9]+}}, %opencl.clk_event_t{{.*}}* addrspace(4)* null,
51+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, 0,
52+
+ ^(void) {
53+
+ return;
54+
+ });
55+
+
56+
// Emits global block literal [[BLG1]] and block kernel [[INVGK1]].
57+
// COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
58+
// COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
59+
@@ -336,7 +343,7 @@ kernel void device_side_enqueue(global int *a, global int *b, int i) {
60+
// COMMON: define internal spir_kernel void [[INVGK5]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
61+
// COMMON: define internal spir_kernel void [[INVGK6]](i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*) #{{[0-9]+}} {
62+
// COMMON: entry:
63+
-// COMMON: call void @__device_side_enqueue_block_invoke_8(i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3)
64+
+// COMMON: call void @__device_side_enqueue_block_invoke_9(i8 addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3)
65+
// COMMON: ret void
66+
// COMMON: }
67+
// COMMON: define internal spir_kernel void [[INVGK7]](i8 addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
68+
--
69+
1.8.3.1
70+

0 commit comments

Comments
 (0)