-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[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
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-powerpc @llvm/pr-subscribers-backend-systemz Author: Guillaume DI FATTA (Atafid) ChangesThis pull request modifies the behavior of the Related Issue: #115733 Testing
Full diff: https://github.com/llvm/llvm-project/pull/117932.diff 6 Files Affected:
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 1ca8c2565ab0b6..ee877349a33149 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -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,
diff --git a/llvm/test/CodeGen/AArch64/stackmap-args.ll b/llvm/test/CodeGen/AArch64/stackmap-args.ll
new file mode 100644
index 00000000000000..0a7b3a4ab1a329
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/stackmap-args.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s
+; This test is expected to fail.
+; XFAIL:*
+
+; Tests failure when we pass non-immediate args to @llvm.experiment.stackmap
+
+define void @first_arg() {
+; CHECK-LABEL: first_arg:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
+; CHECK-NEXT: mov x29, sp
+; CHECK-NEXT: .cfi_def_cfa w29, 16
+; CHECK-NEXT: .cfi_offset w30, -8
+; CHECK-NEXT: .cfi_offset w29, -16
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
+; CHECK-NEXT: ret
+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-LABEL: second_arg:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
+; CHECK-NEXT: mov x29, sp
+; CHECK-NEXT: .cfi_def_cfa w29, 16
+; CHECK-NEXT: .cfi_offset w30, -8
+; CHECK-NEXT: .cfi_offset w29, -16
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
+; CHECK-NEXT: ret
+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, ...)
diff --git a/llvm/test/CodeGen/PowerPC/ppc64-stackmap-args.ll b/llvm/test/CodeGen/PowerPC/ppc64-stackmap-args.ll
new file mode 100644
index 00000000000000..597cc7edf16e18
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/ppc64-stackmap-args.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -verify-machineinstrs < %s -mcpu=ppc -mtriple=powerpc64-unknown-gnu-linux | FileCheck %s
+; This test is expected to fail.
+; XFAIL:*
+
+; Tests failure when we pass non-immediate args to @llvm.experiment.stackmap
+
+define void @first_arg() {
+; CHECK-LABEL: first_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: std 31, -8(1)
+; CHECK-NEXT: stdu 1, -64(1)
+; CHECK-NEXT: std 0, 80(1)
+; CHECK-NEXT: .cfi_def_cfa_offset 64
+; CHECK-NEXT: .cfi_offset r31, -8
+; CHECK-NEXT: .cfi_offset lr, 16
+; CHECK-NEXT: mr 31, 1
+; CHECK-NEXT: .cfi_def_cfa_register r31
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: addi 1, 1, 64
+; CHECK-NEXT: ld 0, 16(1)
+; CHECK-NEXT: ld 31, -8(1)
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+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-LABEL: second_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: std 31, -8(1)
+; CHECK-NEXT: stdu 1, -64(1)
+; CHECK-NEXT: std 0, 80(1)
+; CHECK-NEXT: .cfi_def_cfa_offset 64
+; CHECK-NEXT: .cfi_offset r31, -8
+; CHECK-NEXT: .cfi_offset lr, 16
+; CHECK-NEXT: mr 31, 1
+; CHECK-NEXT: .cfi_def_cfa_register r31
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: addi 1, 1, 64
+; CHECK-NEXT: ld 0, 16(1)
+; CHECK-NEXT: ld 31, -8(1)
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+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, ...)
diff --git a/llvm/test/CodeGen/RISCV/rv64-stackmap-args.ll b/llvm/test/CodeGen/RISCV/rv64-stackmap-args.ll
new file mode 100644
index 00000000000000..1fdf56a563f121
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rv64-stackmap-args.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
+; This test is expected to fail.
+; XFAIL:*
+
+; Tests failure when we pass non-immediate args to @llvm.experiment.stackmap
+
+define void @first_arg() {
+; CHECK-LABEL: first_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: ret
+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-LABEL: second_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: ret
+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, ...)
diff --git a/llvm/test/CodeGen/SystemZ/stackmap-args.ll b/llvm/test/CodeGen/SystemZ/stackmap-args.ll
new file mode 100644
index 00000000000000..1b7767e15eab86
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/stackmap-args.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; This test is expected to fail.
+; XFAIL:*
+
+; Tests failure when we pass non-immediate args to @llvm.experiment.stackmap
+
+define void @first_arg() {
+; CHECK-LABEL: first_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: stmg %r14, %r15, 112(%r15)
+; CHECK-NEXT: .cfi_offset %r14, -48
+; CHECK-NEXT: .cfi_offset %r15, -40
+; CHECK-NEXT: aghi %r15, -160
+; CHECK-NEXT: .cfi_def_cfa_offset 320
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: lmg %r14, %r15, 272(%r15)
+; CHECK-NEXT: br %r14
+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-LABEL: second_arg:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: stmg %r14, %r15, 112(%r15)
+; CHECK-NEXT: .cfi_offset %r14, -48
+; CHECK-NEXT: .cfi_offset %r15, -40
+; CHECK-NEXT: aghi %r15, -160
+; CHECK-NEXT: .cfi_def_cfa_offset 320
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: lmg %r14, %r15, 272(%r15)
+; CHECK-NEXT: br %r14
+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, ...)
diff --git a/llvm/test/CodeGen/X86/stackmap-args.ll b/llvm/test/CodeGen/X86/stackmap-args.ll
new file mode 100644
index 00000000000000..99aefeb8701f2a
--- /dev/null
+++ b/llvm/test/CodeGen/X86/stackmap-args.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck %s
+; This test is expected to fail.
+; XFAIL:*
+
+; Tests failure when we pass non-immediate args to @llvm.experiment.stackmap
+
+define void @first_arg() {
+; CHECK-LABEL: first_arg:
+; CHECK: ## %bb.0: ## %entry
+; CHECK-NEXT: pushq %rbp
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset %rbp, -16
+; CHECK-NEXT: movq %rsp, %rbp
+; CHECK-NEXT: .cfi_def_cfa_register %rbp
+; CHECK-NEXT: Ltmp0:
+; CHECK-NEXT: popq %rbp
+; CHECK-NEXT: retq
+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-LABEL: second_arg:
+; CHECK: ## %bb.0: ## %entry
+; CHECK-NEXT: pushq %rbp
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset %rbp, -16
+; CHECK-NEXT: movq %rsp, %rbp
+; CHECK-NEXT: .cfi_def_cfa_register %rbp
+; CHECK-NEXT: Ltmp1:
+; CHECK-NEXT: popq %rbp
+; CHECK-NEXT: retq
+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, ...)
|
I don't have any comments on the actual change, but this part:
doesn't really match the PR - you add several tests, but they are all XFAILed, so they don't check for specific errors. Usually, to check for a specific error message, you can use the "RUN: not" ... pattern, see e.g.
|
59a4dad
to
4448cfe
Compare
Thank you I didn't know this pattern, I used it to update my tests. |
@uweigand @phoebewang |
The test cases look good to me now. I don't have any additional comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch LG.
I didn't find a description in LangRef. Would be great if it's completed.
4448cfe
to
986c38d
Compare
The documentation seems to be in |
Thanks for the update! Do you need me to merge the patch for you? |
If you have no further comments, I would really appreciate it if you could merge it. Thank you! :) |
@Atafid Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
You are welcome :) |
This pull request modifies the behavior of the
@llvm.experimental.stackmap
intrinsic to require that its two first operands (id
andnumShadowBytes
) be immediate values. This change ensures that variables cannot be passed as two first arguments to this intrinsic.Related Issue: #115733
Testing