[llvm] [llvm][ir]: fix llc crashes on function definitions with label parameters (PR #136285)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 01:44:09 PDT 2025
https://github.com/YLChenZ created https://github.com/llvm/llvm-project/pull/136285
Closes #136144.
After the patch:
```llvm
; label-crash.ll
define void @test(label %0) {
1:
ret void
}
```
```
lambda at ubuntu22:~/test$ llc -o out.s label-crash.ll
Function argument cannot be of label type!
label %0
llc: error: 'label-crash.ll': input module cannot be verified
```
>From 56afe811a36b87ccbca91a651f076ba14b832e3e Mon Sep 17 00:00:00 2001
From: YLChenZ <chentongyongcz at gmail.com>
Date: Fri, 18 Apr 2025 16:32:08 +0800
Subject: [PATCH] [llvm][ir]: fix llc crashes on function definitions with
label parameters
---
llvm/lib/IR/Verifier.cpp | 2 ++
llvm/test/Verifier/invalid-label-param.ll | 7 +++++++
2 files changed, 9 insertions(+)
create mode 100644 llvm/test/Verifier/invalid-label-param.ll
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 35c4d60cf325e..274c60af52e76 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2931,6 +2931,8 @@ void Verifier::visitFunction(const Function &F) {
FT->getParamType(i));
Check(Arg.getType()->isFirstClassType(),
"Function arguments must have first-class types!", &Arg);
+ Check(!Arg.getType()->isLabelTy(),
+ "Function argument cannot be of label type!", &Arg);
if (!IsIntrinsic) {
Check(!Arg.getType()->isMetadataTy(),
"Function takes metadata but isn't an intrinsic", &Arg, &F);
diff --git a/llvm/test/Verifier/invalid-label-param.ll b/llvm/test/Verifier/invalid-label-param.ll
new file mode 100644
index 0000000000000..6654c81a1754c
--- /dev/null
+++ b/llvm/test/Verifier/invalid-label-param.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+define void @invalid_arg_type(label %p) {
+; CHECK: Function argument cannot be of label type!
+ ret void
+}
+
More information about the llvm-commits
mailing list