Add SPV_INTEL_memory_access_aliasing extension #457
Thanks, LGTM!
Actually, I do have one question: Could we consider these new instructions "Annotation" instructions, and drop this rule?
If not, should these be considered some new type of instruction?
I'd remove this optional parameter.
It was added ~because LLVM has it lol~ to a bit improve debuggability for compiler engineers as it tracks from where memory access came from aka which function got inlined by encoding its name.
While it seem to be harmless it actually have tendency to bloat module sizes for C++ based kernel languages with heavy template magic (read: SYCL) after device functions are inlined into a kernel. May be not critical for SPIR-V, but it really increases linkage time on LLVM IR level (via llvm-link) due to metadata serialization things (that is why it got removed even on pre-SPIR-V generation step for SYCL compiler in https://github.com/intel/llvm/pull/20478 )
From implementation stand point: the parameter is never generated by neither llvm-spirv nor SPIR-V backend, so removing it doesn't break anything.
I don't know, what would be an optimal resolution, but if I remember correctly the rule was developed to force generation of these instructions before OpDecorate to avoid potential and undesired forward referencing.
I'd also consider treating these as annotation instructions.
Forward references should be fine: Logical Layout allows them for annotation operands.OpDecorateId requires Extra Operands to be defined before the Target (call/atomic), which should always be true, since functions come last.
No tooling changes would be needed: spirv-val already classifies these as annotations, and llvm-spirv handles any order within the annotation section.
SPIR-V 1.0 isn't enough for the decorations. AliasScopeINTEL/NoAliasINTEL take an <id> Extra Operand, so they must be applied with OpDecorateId, which requires SPIR-V 1.2.
This extension requires SPIR-V 1.2.
OpDecorateId requires its <id> Extra Operands to be constant instructions or OpVariable instructions, and OpAliasScopeListDeclINTEL is neither. Maybe we should add something like this:
--
=== Annotation Instructions
Modify Section 3.3.3, "Annotation Instructions", in the description of *OpDecorateId*, replacing:
"All such <id> Extra Operands must be constant instructions or *OpVariable* instructions."
with:
"All such <id> Extra Operands must be constant instructions or *OpVariable* instructions, except for the *AliasScopeINTEL* and *NoAliasINTEL* decorations, whose <id> Extra Operand must be an *OpAliasScopeListDeclINTEL* instruction."
This extension adds *AliasDomainDeclINTEL*, *AliasScopeDeclINTEL* and
. Optional *OpAliasDomainDeclINTEL*, *OpAliasScopeDeclINTEL* and *OpAliasScopeListDeclINTEL*
Can only be applied to _OpFunctionCall_ and _Atomic_ instructions. Has
Modify Section 3.2.25 "Memory Operands", adding these rows to Memory Operands
Thanks for pointing this out. Removed for both OpAliasDomainDeclINTEL and OpAliasScopeDeclINTEL.
Approved these changes.
LGTM
Merging (offline) as discussed in the September 30th teleconference.
bashbaug
Qi-Ye-079
Please publish the SPV_INTEL_memory_access_aliasing extension.