Skip to content

SPIRVReader: reverse-translated argument types differ from clang output since opaque pointers #3287

@svenvh

Description

@svenvh

The LLVM argument type for any of the OpenCL "Other Built-in Data Types" (such as image types) has changed since the transition to opaque pointers. This only affects the OpenCL target env modes of llvm-spirv.

For example, for the following OpenCL C kernel:

kernel void foo(image2d_t img, global int *out) {
  *out = get_image_channel_data_type(img);
}

clang -target spir currently generates:

call spir_func i32 @_Z27get_image_channel_data_type14ocl_image2d_ro(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %img)

Generating SPIR-V from the above kernel using clang -c --target=spirv64 and taking the SPIR-V through llvm-spirv -r gives:

call spir_func i32 @_Z27get_image_channel_data_type14ocl_image2d_ro(ptr addrspace(1) %img)

That is, the mangled function name remains the same, but the image argument has become a plain pointer instead of a TargetExtType.

My proposal would be to align to clang as closely as possible, so for this case we'd ideally generate TargetExtTypes instead of pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions