[PATCH] D34342: [OpenCL] Fix code generation of function-scope constant samplers.
Anastasia Stulova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 20 08:16:34 PDT 2017
Anastasia added inline comments.
================
Comment at: test/CodeGenOpenCL/sampler.cl:62
+
+ const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+ // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35)
----------------
bader wrote:
> yaxunl wrote:
> > what if address of const_smp is taken and assigned to a pointer to sampler_t ? Do we have diagnosis in place?
> AFAIK, we have diagnostics for both:
> - declaration of a pointer to sampler
> - taking address of sampler variable
Btw, strangely I don't hit any unreachable and don't seem to have any static variable generated either. I was trying to compile this code on r305798:
void fnc4smp(sampler_t s) {}
kernel void foo(sampler_t smp_par) {
const sampler_t const_smp = 0;
fnc4smp(const_smp);
}
This is the IR which is produced for me:
%opencl.sampler_t = type opaque
; Function Attrs: noinline nounwind optnone
define spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* %s) #0 {
entry:
%s.addr = alloca %opencl.sampler_t addrspace(2)*, align 4
store %opencl.sampler_t addrspace(2)* %s, %opencl.sampler_t addrspace(2)** %s.addr, align 4
ret void
}
; Function Attrs: noinline nounwind optnone
define spir_kernel void @foo(%opencl.sampler_t addrspace(2)* %smp_par) #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 {
entry:
%smp_par.addr = alloca %opencl.sampler_t addrspace(2)*, align 4
%const_smp = alloca %opencl.sampler_t addrspace(2)*, align 4
store %opencl.sampler_t addrspace(2)* %smp_par, %opencl.sampler_t addrspace(2)** %smp_par.addr, align 4
%0 = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 0)
store %opencl.sampler_t addrspace(2)* %0, %opencl.sampler_t addrspace(2)** %const_smp, align 4
%1 = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** %const_smp, align 4
call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* %1)
ret void
}
declare %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32)
https://reviews.llvm.org/D34342
More information about the cfe-commits
mailing list