OpenCL types mangling.


I’d like to discuss current mangling rules for OpenCL built-in types.

OpenCL specification defines number of built-in types:

  • Vector types e.g. int4, half8, etc.

  • Image types e.g. image2d_t, image

  • Sampler type – sampler_t

All those types are mangled by clang using Itanium C++ ABI, which doesn’t describe mangling of OpenCL types, but if we extend it naturally, OpenCL built-in types should be excluded from substitution as built-in type. BTW, it’s the way how SPIR 1.2 defines it (appending A of

Clang 3.6+ substitutes OpenCL built-in types although they were not compressed before this commit. This looks like unintentional change.

Unfortunately recovering original behavior will solve the problem only partially.

OpenCL built-in vector types are implemented not as Clang’s built-in types, but as vector extension types, so they will require special case in mangler.

I’d like to have an agreement within clang community on how to handle substitution of OpenCL built-in types since it’s not part of the OpenCL specification, but rather internal compiler design. Is it OK to disable OpenCL built-in type compression? The only con of this approach is the length of mangled types. If I get it correctly built-in types are exceptions because their compression will not reduce the size of the mangled name and for some types even increase.

Does it worth documenting mangling rules for OpenCL built-in types?

  • Alexey

I suggest following SPIR on this.