Skip to content

[llvm][ir]: fix llc crashes on function definitions with label parameters #136285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking arguments on the function not calls.

Though really, we should not allow labels as inline asm operands either -- it looks like this is some leftover from an old implementation the predates both blockaddresses and callbr.

"Function argument cannot be of label type!", &Arg, &F);
if (!IsIntrinsic) {
Check(!Arg.getType()->isMetadataTy(),
"Function takes metadata but isn't an intrinsic", &Arg, &F);
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Verifier/invalid-label-param.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s

define void @invalid_arg_type(i32 %0) {
1:
call void @foo(label %1)
ret void
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for call site, e.g.:

define void @test(i32 %0) {
1:
  call void @foo(label %1)
  ret void
}

declare void @foo(label)

declare void @foo(label)
; CHECK: Function argument cannot be of label type!
; CHECK-NEXT: label %0
; CHECK-NEXT: ptr @foo


Loading