diff options
author | Alexey Bader <alexey.bader@intel.com> | 2017-11-15 11:38:17 +0000 |
---|---|---|
committer | Alexey Bader <alexey.bader@intel.com> | 2017-11-15 11:38:17 +0000 |
commit | 0f512ed5d31bb3b8aa0b07d50e37735c02600b51 (patch) | |
tree | 1b62e91d7e7307ba642f412ac718c72d8200391f /test/CodeGenOpenCL | |
parent | c0576335506e05f53c2c05690246811da220a9a7 (diff) |
[OpenCL] Fix code generation of function-scope constant samplers.
Summary:
Constant samplers are handled as static variables and clang's code generation
library, which leads to llvm::unreachable. We bypass emitting sampler variable
as static since it's translated to a function call later.
Reviewers: yaxunl, Anastasia
Reviewed By: yaxunl, Anastasia
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D34342
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318290 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenOpenCL')
-rw-r--r-- | test/CodeGenOpenCL/sampler.cl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGenOpenCL/sampler.cl b/test/CodeGenOpenCL/sampler.cl index 3a7319cd78..22976c5766 100644 --- a/test/CodeGenOpenCL/sampler.cl +++ b/test/CodeGenOpenCL/sampler.cl @@ -20,6 +20,8 @@ constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; // CHECK-NOT: glb_smp +int get_sampler_initializer(void); + void fnc4smp(sampler_t s) {} // CHECK: define spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* % @@ -58,4 +60,20 @@ kernel void foo(sampler_t smp_par) { fnc4smp(5); // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(const_smp); + // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]] + fnc4smp(const_smp); + // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]] + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(constant_smp); + // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + // TODO: enable sampler initialization with non-constant integer. + //const sampler_t const_smp_func_init = get_sampler_initializer(); } |