[libspirv] Replace libclc-remangler with SYCLRemangleLibspirvPass (#21588)
Remove libclc-remangler tool and replace it with
SYCLRemangleLibspirvPass
that remangles OpenCL C mangling in libspirv to match with SYCL
mangling.
The pass ports the functionalities in the tool into compile pipeline.
Motivation:
- libclc-remangler executable doesn't fit in runtime build.
- libclc-remangler can't justify as a standalone tool in llvm/tools.
Functional changes:
- Add SYCLRemangleLibspirvPass. It uses Itanium demangler and adapts
SPIR type system and SPIR mangler from SPIRV-LLVM-Translator.
- The pass runs at the end of compile pipeline for each .cl file.
libspirv variants are created without separate remangling step.
- Drop libclc-remangler tool.
llvm-diff changes to remangled libspirv:
- __clc_ functions from CLC library are now not remangled because we use
a single clc library that defaults to OpenCL C mangling.
- Some __clc_ functions from CLC library are no longer inlined for
NVPTX.
Previously, these were called only once and inlined before remangling.
Now, because remangling can generate two caller variants, the __clc_
function is called twice, causing the inliner to skip them.
- Changes in _CLC_DEFINE_MIPMAP_BINDLESS_READS_BUILTIN also exposed a
bug in libclc-remangler which would remangle
_Z30__spirv_ImageSampleExplicitLodImDv4_cDv3_fET0_T_T1_iS4_S4_ (correct)
to _Z30__spirv_ImageSampleExplicitLodImDv4_aDv3_fET0_T_T1_iS1_S1_
This bug was hidden since correct symbol was hardcoded in the source.
- Fixed 4 __spirv_ImageArrayWrite builtins in nvptx l64.signed_char,
e.g.
_Z23__spirv_ImageArrayWriteIyiiEvT_T0_T1_i ->
_Z23__spirv_ImageArrayWriteIyiiEvT_T0_iT1_;
_Z23__spirv_ImageArrayWriteImiiEvT_T0_T1_i ->
_Z23__spirv_ImageArrayWriteImiiEvT_T0_iT1_.
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>