[llvm] [AsmPrinter] Do not emit label instructions after the function body if the target is SPIR-V (PR #107013)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 02:14:41 PDT 2024
Keenuts wrote:
> I am not familiar with SPIR-V but isn't this SPIR-V tooling issue? It's fairly common to have the following assembly construct
>
> ```
> begin:
> begin_instruction
> ...
> end_instruction
> end:
> ```
>
> then you can use `end-begin` to get the size of the function. Defining a label just past the last byte of the body is normal. I understand that each target may have its own special properties but this one might break LLVM's assumption badly.
This is a hard SPIR-V requirement, not a tooling issue.
SPIR-V is not a assembly language in which instructions have addresses. The label is a the start of a logical basic block, and not an "address marker".
```
A block always starts with an [OpLabel](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpLabel) instruction. This may be immediately preceded by an [OpLine](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpLine) instruction, but the OpLabel is considered as the beginning of the block.
A block always ends with a [block termination instruction](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Termination) (see [validation rules](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Validation) for more detail).
```
https://github.com/llvm/llvm-project/pull/107013
More information about the llvm-commits
mailing list