Repository navigation
Sanitize linkage names that aren't valid C identifiers - #28
Merged
Merged
Conversation
Linkage names were reserved verbatim, so an exported function named like
LLVM's SPIR-V back-end helpers ("spirv.llvm_fshl_i64", emitted for funnel
shifts) produced uncompilable OpenCL C. Such a name can't be kept anyway, so
sanitize it like an OpName, after all names that are kept verbatim have been
reserved so that it can't take one of them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLVM's SPIR-V back-end lowers funnel shifts (
llvm.fshl/llvm.fshr) into helper functions with exported linkage names likespirv.llvm_fshl_i64. Linkage names were used verbatim as C identifiers, so the translation containedulong spirv.llvm_fshl_i64(...)and failed to compile. This breaks OpenCL.jl's OpenCL C source path for any kernel that rotates an integer (e.g.bitrotate, or the hashing in GPUArrays'findfirstand reductions), and is what fails OpenCL.jl'spoclctests on JuliaGPU/GPUCompiler.jl#1027.A linkage name that isn't a valid identifier can't be kept, so it is now sanitized like an OpName (
spirv_llvm_fshl_i64). That happens after all names that are kept verbatim have been reserved, so a sanitized name can't take one of them. Entry-point names are left alone, since kernels are looked up by them.With this, the failing OpenCL.jl testsets (
gpuarrays/reductions/sum prod,== isequalandindexing findon PoCL's source path) pass with GPUCompiler.jl#1027.