[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
Mon Sep 16 01:51:09 PDT 2024
https://github.com/VyacheslavLevytskyy updated https://github.com/llvm/llvm-project/pull/107013
>From 95eb6f4859decb56c79f25f5c77ea71a1c9f7547 Mon Sep 17 00:00:00 2001
From: "Levytskyy, Vyacheslav" <vyacheslav.levytskyy at intel.com>
Date: Mon, 2 Sep 2024 11:21:19 -0700
Subject: [PATCH 1/2] do not emit label instructions after the function body if
the target is SPIR-V
---
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 +++-
llvm/test/CodeGen/SPIRV/debug-info/basic-global-di.ll | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 19d23c8ba96783..439aefccb59b26 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -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))) {
// Create a symbol for the end of function.
CurrentFnEnd = createTempSymbol("func_end");
OutStreamer->emitLabel(CurrentFnEnd);
diff --git a/llvm/test/CodeGen/SPIRV/debug-info/basic-global-di.ll b/llvm/test/CodeGen/SPIRV/debug-info/basic-global-di.ll
index 139a8e11182bcc..a63f01b8c64a24 100644
--- a/llvm/test/CodeGen/SPIRV/debug-info/basic-global-di.ll
+++ b/llvm/test/CodeGen/SPIRV/debug-info/basic-global-di.ll
@@ -29,11 +29,13 @@ define spir_func void @foo() {
entry:
ret void
}
+; CHECK-SPIRV-NOT: Lfunc_end0:
define spir_func void @bar() {
entry:
ret void
}
+; CHECK-SPIRV-NOT: Lfunc_end1:
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5}
>From be842b5abd27a429d41b35981421f72c148170d4 Mon Sep 17 00:00:00 2001
From: "Levytskyy, Vyacheslav" <vyacheslav.levytskyy at intel.com>
Date: Mon, 16 Sep 2024 01:50:57 -0700
Subject: [PATCH 2/2] change target test to a test of the SPIRV object format
---
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 439aefccb59b26..010debfac808d3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1962,7 +1962,8 @@ void AsmPrinter::emitFunctionBody() {
// SPIR-V supports label instructions only inside a block, not after the
// function body.
- if (!TT.isSPIRV() && (EmitFunctionSize || needFuncLabels(*MF, *this))) {
+ if (TT.getObjectFormat() != Triple::SPIRV &&
+ (EmitFunctionSize || needFuncLabels(*MF, *this))) {
// Create a symbol for the end of function.
CurrentFnEnd = createTempSymbol("func_end");
OutStreamer->emitLabel(CurrentFnEnd);
More information about the llvm-commits
mailing list