Skip to content

[CodeGen] @llvm.experimental.stackmap make operands immediate #117932

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 1 commit into from
Dec 11, 2024
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
5 changes: 3 additions & 2 deletions llvm/docs/StackMaps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ Operands:

The first operand is an ID to be encoded within the stack map. The
second operand is the number of shadow bytes following the
intrinsic. The variable number of operands that follow are the ``live
values`` for which locations will be recorded in the stack map.
intrinsic. These first two operands should be immediate, e.g. cannot
be passed as variables. The variable number of operands that follow are
the ``live values`` for which locations will be recorded in the stack map.

To use this intrinsic as a bare-bones stack map, with no code patching
support, the number of shadow bytes can be set to zero.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
//
def int_experimental_stackmap : DefaultAttrsIntrinsic<[],
[llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
[Throws]>;
[Throws, ImmArg<ArgIndex<0>>, ImmArg<ArgIndex<1>>]>;
def int_experimental_patchpoint_void : Intrinsic<[],
[llvm_i64_ty, llvm_i32_ty,
llvm_ptr_ty, llvm_i32_ty,
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AArch64/stackmap-args.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -mtriple=arm64-linux-gnu < %s 2>&1 | FileCheck %s
; Tests error when we pass non-immediate parameters to @llvm.experiment.stackmap

define void @first_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; First operand should be immediate
%id = add i64 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 %id, i32 0)
ret void
}

define void @second_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; Second operand should be immediate
%numShadowByte = add i32 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 %numShadowByte)
ret void
}

declare void @llvm.experimental.stackmap(i64, i32, ...)
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/PowerPC/ppc64-stackmap-args.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -verify-machineinstrs -mcpu=ppc -mtriple=powerpc64-unknown-gnu-linux < %s 2>&1 | FileCheck %s
; Tests error when we pass non-immediate parameters to @llvm.experiment.stackmap

define void @first_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; First operand should be immediate
%id = add i64 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 %id, i32 0)
ret void
}

define void @second_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; Second operand should be immediate
%numShadowByte = add i32 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 %numShadowByte)
ret void
}

declare void @llvm.experimental.stackmap(i64, i32, ...)
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/RISCV/rv64-stackmap-args.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -mtriple=riscv64 < %s 2>&1 | FileCheck %s
; Tests error when we pass non-immediate parameters to @llvm.experiment.stackmap

define void @first_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; First operand should be immediate
%id = add i64 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 %id, i32 0)
ret void
}

define void @second_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; Second operand should be immediate
%numShadowByte = add i32 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 %numShadowByte)
ret void
}

declare void @llvm.experimental.stackmap(i64, i32, ...)
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/SystemZ/stackmap-args.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -mtriple=s390x-linux-gnu < %s 2>&1 | FileCheck %s
; Tests error when we pass non-immediate parameters to @llvm.experiment.stackmap

define void @first_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; First operand should be immediate
%id = add i64 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 %id, i32 0)
ret void
}

define void @second_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; Second operand should be immediate
%numShadowByte = add i32 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 %numShadowByte)
ret void
}

declare void @llvm.experimental.stackmap(i64, i32, ...)
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/X86/stackmap-args.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -mtriple=x86_64-apple-darwin -mcpu=corei7 < %s 2>&1 | FileCheck %s
; Tests error when we pass non-immediate parameters to @llvm.experiment.stackmap

define void @first_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; First operand should be immediate
%id = add i64 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 %id, i32 0)
ret void
}

define void @second_arg() {
; CHECK: immarg operand has non-immediate parameter
entry:
; Second operand should be immediate
%numShadowByte = add i32 0, 0
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 1, i32 %numShadowByte)
ret void
}

declare void @llvm.experimental.stackmap(i64, i32, ...)
Loading