[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 00:34:00 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:
Let's recap it:
1) AsmPrinter generates invalid SPIR-V because needFuncLabels() is inside the OR condition and returns true, and needFuncLabels() is a static function,
2) needFuncLabels() returns true because Asm.hasDebugInfo() is inside the OR condition and returns true, and Asm.hasDebugInfo() just returns DbgInfoAvailable,
3) DbgInfoAvailable is a private class member and it's true if valid debug info is present.
4) In the very same code (actually, for the very same if) we have a check for the triple in `TT.isWasm()`.
https://github.com/llvm/llvm-project/pull/107013
More information about the llvm-commits
mailing list