[llvm] [AsmPrinter] Do not emit label instructions after the function body if the target is SPIR-V (PR #107013)
Vyacheslav Levytskyy via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 09:07:13 PDT 2024
================
@@ -1960,7 +1960,9 @@ void AsmPrinter::emitFunctionBody() {
// are automatically sized.
bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective() && !TT.isWasm();
- if (EmitFunctionSize || needFuncLabels(*MF, *this)) {
+ // SPIR-V supports label instructions only inside a block, not after the
+ // function body.
+ if (!TT.isSPIRV() && (EmitFunctionSize || needFuncLabels(*MF, *this))) {
----------------
VyacheslavLevytskyy wrote:
I'd say that in case of SPIR-V we have a peculiar situation, when we should not talk about the target per se, separately from the format. The reason for this is that SPIR-V is a higher level representation, as LLVM IR, and this differs it from other lower-level backends.
In case of SPIR-V both the SPIR-V target (behavior/properties) and the SPIR-V representation (format) are artefacts of the SPIR-V specification -- the SPIR-V target does not have in mind any *real* target, it's just an intermediate format, as abstract as the format is.
The SPIR-V specification dictates that a label may appear only inside the block (and so not outside of a function). Given the abstract nature and full congruence of SPIR-V target and format, there is no and will never be a format for the SPIR-V target that allows labels outside of a function, because the format in this case is a material embodiment of the abstract target.
https://github.com/llvm/llvm-project/pull/107013
More information about the llvm-commits
mailing list