-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor handling of untyped pointers in builtins reverse translation #2924
Refactor handling of untyped pointers in builtins reverse translation #2924
Conversation
test/transcoding/enqueue_kernel.cl
Outdated
@@ -72,6 +85,8 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) { | |||
// CHECK-LLVM: [[BlockInv2:%[0-9]+]] = addrspacecast ptr @__device_side_enqueue_block_invoke_kernel to ptr addrspace(4) | |||
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_basic(ptr {{.*}}, i32 {{.*}}, ptr {{.*}}, ptr addrspace(4) [[BlockInv2]], ptr addrspace(4) [[Block2Ptr]]) | |||
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii(target("spirv.Queue") {{.*}}, i32 {{.*}}, ptr {{.*}}, i32 0, ptr addrspace(4) null, ptr addrspace(4) null, ptr @__device_side_enqueue_block_invoke_kernel, ptr addrspace(4) {{.*}}, i32 {{.*}}, i32 {{.*}}) | |||
// _Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS412structtype.0ii | |||
// Actuallly the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Actuallly the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char. | |
// Actually the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char. |
or was it left just for the review? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You talk here about Param
operand of OpEnqueueKernel
, right? What is the type of it in the generated by the translator SPIR-V module?
About the mangling, I believe, that if the SPIR-V spec mandates, that Param is char *, the SPIR-V friendly LLVM IR must follow and hence the mangling should not encode the struct type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this comment was for review :)
In SPIR-V we have untyped pointer (which untyped variable points to struct type). With "usual" pointers we have the same pointer to struct, just casted to pointer to char.
I believe you're right, we should not encode the struct type in this special case.
This fixes the mangling in
enqueue_kernel.cl
test.Without the fix we get such mangled function:
instead of the expected: