You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ability to preserve all function metadata and attributes from LLVM-IR
Initial implementation of function metadata and attribute preservation
In Intel's SYCL compiler, we have a use case where we need to convert to SPIR-V and then back to LLVM-IR and preserve all function metadata and attributes. The metadata and attributes we need to preserve have no value outside an internal stage of Intel's SYCL compiler and are not good fits for SPIR-V extensions. The list of what is needed is very volatile as well.
To implement generic support in the translator, the general approach is to use SPV_KHR_non_semantic_info to add a new nonsemantic EIS, named NonSemantic.AuxData
This new instruction set has two instructions:
NonSemanticAuxDataFunctionMetadata
and
NonSemanticAuxDataFunctionAttribute
Both instructions will be placed outside of the function CFG and take in what function to target as an operand, similar to debuginfo. We do this to support function declarations.
The operands after the function to target are either strings or values describing the metadata or attribute. Specific information can be found in the SPIRVWriter.cpp changes.
I also added a new option, --spirv-preserve-auxdata to preserve these.
If a flag is passed for translation to SPIR-V the respective information will be preserved as described above. The flag is also required for reverse translation. If it not provided, it will be dropped as allowed in the spec.
In order to handle the case of some metadata/attributes being handled manually (maybe we have metadata "foo=bar" in LLVM-IR, but we translate to "foo=oof" for some reason in SPIR-V (and thus reverse translation)), we process these new instructions very late in reverse translation, and if the metadata or attribute already exists, we skip it.
Signed-off-by: Sarnie, Nick <[email protected]>
Original commit:
KhronosGroup/SPIRV-LLVM-Translator@f729c49
0 commit comments