r278234 - [OpenCL] Change block descriptor address space to constant.
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 10 10:25:27 PDT 2016
Hi Hans,
Is it still possible to merge this change in release 3.9 branch. This is just a minor bug fix we have found with Clang Blocks and only affects OpenCL.
PS, it goes together with a typo fix in the next commit r278235.
Thanks in advance,
Anastasia
-----Original Message-----
From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On Behalf Of Joey Gouly via cfe-commits
Sent: 10 August 2016 16:57
To: cfe-commits at lists.llvm.org
Subject: r278234 - [OpenCL] Change block descriptor address space to constant.
Author: joey
Date: Wed Aug 10 10:57:02 2016
New Revision: 278234
URL: http://llvm.org/viewvc/llvm-project?rev=278234&view=rev
Log:
[OpenCL] Change block descriptor address space to constant.
The block descriptor is a GlobalVariable in the LLVM IR, so it shouldn't be in the private address space.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=278234&r1=278233&r2=278234&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Aug 10 10:57:02 2016
@@ -125,10 +125,15 @@ static llvm::Constant *buildBlockDescrip
llvm::Constant *init = llvm::ConstantStruct::getAnon(elements);
+ unsigned AddrSpace = 0;
+ if (C.getLangOpts().OpenCL)
+ AddrSpace = C.getTargetAddressSpace(LangAS::opencl_constant);
llvm::GlobalVariable *global =
new llvm::GlobalVariable(CGM.getModule(), init->getType(), true,
llvm::GlobalValue::InternalLinkage,
- init, "__block_descriptor_tmp");
+ init, "__block_descriptor_tmp", nullptr,
+ llvm::GlobalValue::NotThreadLocal,
+ AddrSpace);
return llvm::ConstantExpr::getBitCast(global, CGM.getBlockDescriptorType()); } @@ -927,7 +932,10 @@ llvm::Type *CodeGenModule::getBlockDescr
UnsignedLongTy, UnsignedLongTy, nullptr);
// Now form a pointer to that.
- BlockDescriptorType = llvm::PointerType::getUnqual(BlockDescriptorType);
+ unsigned AddrSpace = 0;
+ if (getLangOpts().OpenCL)
+ AddrSpace =
+ getContext().getTargetAddressSpace(LangAS::opencl_constant);
+ BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType,
+ AddrSpace);
return BlockDescriptorType;
}
Modified: cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl?rev=278234&r1=278233&r2=278234&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Wed Aug 10
+++ 10:57:02 2016
@@ -5,7 +5,7 @@ typedef void (^bl_t)(local void *); const bl_t block_G = (bl_t) ^ (local void *a) {};
kernel void device_side_enqueue(global int *a, global int *b, int i) {
- // CHECK: %default_queue = alloca %opencl.queue_t*
+ // CHECK: %deafault_queue = alloca %opencl.queue_t*
queue_t default_queue;
// CHECK: %flags = alloca i32
unsigned flags = 0;
@@ -21,7 +21,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
// CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
- // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()*
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*,
+ %struct.__block_descriptor addrspace(3)*, i32{{.*}}, i32{{.*}},
+ i32{{.*}} }>* %block to void ()*
// CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
// CHECK: call i32 @__enqueue_kernel_basic(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* [[BL_I8]])
enqueue_kernel(default_queue, flags, ndrange, @@ -32,7 +32,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
// CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
- // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*,
+ %struct.__block_descriptor addrspace(3)*, i32{{.*}}, i32{{.*}},
+ i32{{.*}} }>* %block3 to void ()*
// CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
// CHECK: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** %event_wait_list, %opencl.clk_event_t** %clk_event, i8* [[BL_I8]])
enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event, @@ -43,7 +43,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
// CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
- // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*,
+ i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32
+ [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32,
+ i8*, %struct.__block_descriptor addrspace(3)* }*
+ @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
enqueue_kernel(default_queue, flags, ndrange,
^(local void *p) {
return;
@@ -54,7 +54,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
// CHECK: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i32
- // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*,
+ i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32
+ [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32,
+ i8*, %struct.__block_descriptor addrspace(3)* }*
+ @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
enqueue_kernel(default_queue, flags, ndrange,
^(local void *p) {
return;
@@ -65,7 +65,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
// CHECK: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
- // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32,
+ %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...)
+ @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32
+ [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t**
+ [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32,
+ i32, i8*, %struct.__block_descriptor addrspace(3)* }*
+ @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event,
^(local void *p) {
return;
@@ -77,7 +77,7 @@ kernel void device_side_enqueue(global i
// CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
// CHECK: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
// CHECK: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i32
- // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32,
+ %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...)
+ @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32
+ [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t**
+ [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32,
+ i32, i8*, %struct.__block_descriptor addrspace(3)* }*
+ @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event,
^(local void *p) {
return;
_______________________________________________
cfe-commits mailing list
cfe-commits at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list