From 2c174a53d50bff301234c08d9ba130e1f0d22e28 Mon Sep 17 00:00:00 2001 From: gonglingqin Date: Sat, 7 Jan 2023 10:38:41 +0800 Subject: [PATCH] [LoongArch] Move illegal ImmArg tests to llvm/test/Verifier This patch also fixes incorrect function declarations in test cases and remove -disable-verify from the test case. Fix https://github.com/llvm/llvm-project/issues/59839 --- .../LoongArch/frameaddr-returnaddr-error.ll | 24 ---------------------- .../test/CodeGen/LoongArch/intrinsic-la32-error.ll | 10 ++++----- llvm/test/CodeGen/LoongArch/returnaddr-error.ll | 9 ++++++++ llvm/test/Verifier/LoongArch/intrinsic-immarg.ll | 20 ++++++++++++++++++ llvm/test/Verifier/LoongArch/lit.local.cfg | 2 ++ 5 files changed, 36 insertions(+), 29 deletions(-) delete mode 100644 llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll create mode 100644 llvm/test/CodeGen/LoongArch/returnaddr-error.ll create mode 100644 llvm/test/Verifier/LoongArch/intrinsic-immarg.ll create mode 100644 llvm/test/Verifier/LoongArch/lit.local.cfg diff --git a/llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll b/llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll deleted file mode 100644 index 10fcdf2..0000000 --- a/llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll +++ /dev/null @@ -1,24 +0,0 @@ -; RUN: not llc --mtriple=loongarch64 --disable-verify < %s 2>&1 | FileCheck %s - -declare ptr @llvm.frameaddress(i32) -declare ptr @llvm.returnaddress(i32) - -define ptr @non_const_depth_frameaddress(i32 %x) nounwind { -; CHECK: argument to '__builtin_frame_address' must be a constant integer - %1 = call ptr @llvm.frameaddress(i32 %x) - ret ptr %1 -} - - -define ptr @non_const_depth_returnaddress(i32 %x) nounwind { -; CHECK: argument to '__builtin_return_address' must be a constant integer - %1 = call ptr @llvm.returnaddress(i32 %x) - ret ptr %1 -} - -define ptr @non_zero_returnaddress() nounwind { -; CHECK: return address can only be determined for the current frame - %1 = call ptr @llvm.returnaddress(i32 1) - ret ptr %1 -} - diff --git a/llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll b/llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll index 4b38e6c..c915161 100644 --- a/llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll +++ b/llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll @@ -1,4 +1,4 @@ -; RUN: not llc --mtriple=loongarch32 --disable-verify < %s 2>&1 | FileCheck %s +; RUN: not llc --mtriple=loongarch32 < %s 2>&1 | FileCheck %s declare void @llvm.loongarch.cacop.w(i32, i32, i32) declare i32 @llvm.loongarch.crc.w.b.w(i32, i32) @@ -16,8 +16,8 @@ declare i64 @llvm.loongarch.iocsrrd.d(i32) declare void @llvm.loongarch.iocsrwr.d(i64, i32) declare void @llvm.loongarch.asrtle.d(i64, i64) declare void @llvm.loongarch.asrtgt.d(i64, i64) -declare i64 @llvm.loongarch.lddir.d(i64, i32) -declare void @llvm.loongarch.ldpte.d(i64, i32) +declare i64 @llvm.loongarch.lddir.d(i64, i64 immarg) +declare void @llvm.loongarch.ldpte.d(i64, i64 immarg) define void @cacop_arg0_out_of_hi_range(i32 %a) nounwind { ; CHECK: argument to 'llvm.loongarch.cacop.w' out of range @@ -155,13 +155,13 @@ entry: define i64 @lddir_d(i64 %a) { ; CHECK: llvm.loongarch.lddir.d requires target: loongarch64 entry: - %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i32 1) + %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i64 1) ret i64 %0 } define void @ldpte_d(i64 %a) { ; CHECK: llvm.loongarch.ldpte.d requires target: loongarch64 entry: - tail call void @llvm.loongarch.ldpte.d(i64 %a, i32 1) + tail call void @llvm.loongarch.ldpte.d(i64 %a, i64 1) ret void } diff --git a/llvm/test/CodeGen/LoongArch/returnaddr-error.ll b/llvm/test/CodeGen/LoongArch/returnaddr-error.ll new file mode 100644 index 0000000..6ac1e0a --- /dev/null +++ b/llvm/test/CodeGen/LoongArch/returnaddr-error.ll @@ -0,0 +1,9 @@ +; RUN: not llc --mtriple=loongarch64 < %s 2>&1 | FileCheck %s + +declare ptr @llvm.returnaddress(i32 immarg) + +define ptr @non_zero_returnaddress() nounwind { +; CHECK: return address can only be determined for the current frame + %1 = call ptr @llvm.returnaddress(i32 1) + ret ptr %1 +} diff --git a/llvm/test/Verifier/LoongArch/intrinsic-immarg.ll b/llvm/test/Verifier/LoongArch/intrinsic-immarg.ll new file mode 100644 index 0000000..488f77f --- /dev/null +++ b/llvm/test/Verifier/LoongArch/intrinsic-immarg.ll @@ -0,0 +1,20 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s + +declare ptr @llvm.frameaddress(i32 immarg) +declare ptr @llvm.returnaddress(i32 immarg) + +define ptr @non_const_depth_frameaddress(i32 %x) nounwind { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %x + ; CHECK-NEXT: %1 = call ptr @llvm.frameaddress.p0(i32 %x) + %1 = call ptr @llvm.frameaddress(i32 %x) + ret ptr %1 +} + +define ptr @non_const_depth_returnaddress(i32 %x) nounwind { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %x + ; CHECK-NEXT: %1 = call ptr @llvm.returnaddress(i32 %x) + %1 = call ptr @llvm.returnaddress(i32 %x) + ret ptr %1 +} diff --git a/llvm/test/Verifier/LoongArch/lit.local.cfg b/llvm/test/Verifier/LoongArch/lit.local.cfg new file mode 100644 index 0000000..2b5a489 --- /dev/null +++ b/llvm/test/Verifier/LoongArch/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'LoongArch' in config.root.targets: + config.unsupported = True -- 2.7.4