Hi all,
I was looking into lowering GPU kernels into SPIR-V and passing that to intel graphics compiler without the use of external SPIR-V translator. The exposed SPIR-V built-ins (e.g., __spirv_BuiltInWorkgroupSize) have to be mangled to be processed correctly by the underlying stack. Same goes to OpenCL C built-in function calls (like get_local_id). Those allow overloading and do not provide intrinsics (I found this old post on the topic SPIR - Built-ins and Name Mangling discussion).
The mangling scheme for both is basically Itanium (Khronos’ translator replicates the mangler with slight deviations), so putting the same code for mangling inside LLVM itself (currently it is in Clang) would be duplication. Using Clang’s mangler also doesn’t seem appealing for projects with a different frontend. And moving the mangler from Clang to LLVM sounds like a ton of work (and I expect a lot of “whys”).
So I wonder if this is the only use case. I’d expect custom frontends (I’m thinking MLIR) to want to be able to emit some external function calls and mangle them in certain cases like the one I encountered. Is it only OpenCL or are there any other scenarios that may benefit?