[llvm] 4acc8ee - [SCCP] Generate test checks (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 03:32:59 PDT 2024
Author: Nikita Popov
Date: 2024-06-25T12:32:49+02:00
New Revision: 4acc8eed94e3f4e21bcf1dedca021cb6a086720c
URL: https://github.com/llvm/llvm-project/commit/4acc8eed94e3f4e21bcf1dedca021cb6a086720c
DIFF: https://github.com/llvm/llvm-project/commit/4acc8eed94e3f4e21bcf1dedca021cb6a086720c.diff
LOG: [SCCP] Generate test checks (NFC)
Some of these are just old, while others previously did not use
UTC due to missing features that have since been implemented
(such as signature matching).
Added:
Modified:
llvm/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll
llvm/test/Transforms/SCCP/apint-ipsccp2.ll
llvm/test/Transforms/SCCP/ipsccp-clear-returned.ll
llvm/test/Transforms/SCCP/ipsccp-noundef.ll
llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
llvm/test/Transforms/SCCP/range-and-ip.ll
llvm/test/Transforms/SCCP/solve-after-each-resolving-undefs-for-function.ll
llvm/test/Transforms/SCCP/struct-arg-resolve-undefs.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll b/llvm/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll
index 6ca5faabdd0f2..3fb9c8885f662 100644
--- a/llvm/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll
+++ b/llvm/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll
@@ -1,22 +1,35 @@
-; RUN: opt < %s -passes=ipsccp -S | grep "ret i32 42"
-; RUN: opt < %s -passes=ipsccp -S | grep "ret i32 undef"
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
; PR3325
define i32 @main() personality ptr @__gxx_personality_v0 {
- %tmp1 = invoke i32 @f()
- to label %UnifiedReturnBlock unwind label %lpad
+; CHECK-LABEL: define i32 @main() personality ptr @__gxx_personality_v0 {
+; CHECK-NEXT: [[TMP1:%.*]] = invoke i32 @f()
+; CHECK-NEXT: to label %[[UNIFIEDRETURNBLOCK:.*]] unwind label %[[LPAD:.*]]
+; CHECK: [[LPAD]]:
+; CHECK-NEXT: [[VAL:%.*]] = landingpad { ptr, i32 }
+; CHECK-NEXT: cleanup
+; CHECK-NEXT: unreachable
+; CHECK: [[UNIFIEDRETURNBLOCK]]:
+; CHECK-NEXT: ret i32 42
+;
+ %tmp1 = invoke i32 @f()
+ to label %UnifiedReturnBlock unwind label %lpad
lpad:
- %val = landingpad { ptr, i32 }
- cleanup
- unreachable
+ %val = landingpad { ptr, i32 }
+ cleanup
+ unreachable
UnifiedReturnBlock:
- ret i32 %tmp1
+ ret i32 %tmp1
}
define internal i32 @f() {
- ret i32 42
+; CHECK-LABEL: define internal i32 @f() {
+; CHECK-NEXT: ret i32 undef
+;
+ ret i32 42
}
declare ptr @__cxa_begin_catch(ptr) nounwind
diff --git a/llvm/test/Transforms/SCCP/apint-ipsccp2.ll b/llvm/test/Transforms/SCCP/apint-ipsccp2.ll
index 7f41d863f66fc..4f2fcd3bdb0a1 100644
--- a/llvm/test/Transforms/SCCP/apint-ipsccp2.ll
+++ b/llvm/test/Transforms/SCCP/apint-ipsccp2.ll
@@ -1,19 +1,29 @@
-; RUN: opt < %s -passes=ipsccp -S | grep -v "ret i101 0" | \
-; RUN: grep -v "ret i101 undef" | not grep ret
-
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
define internal i101 @bar(i101 %A) {
- %x = icmp eq i101 %A, 0
- br i1 %x, label %T, label %F
+; CHECK-LABEL: define internal i101 @bar(
+; CHECK-SAME: i101 [[A:%.*]]) {
+; CHECK-NEXT: br label %[[T:.*]]
+; CHECK: [[T]]:
+; CHECK-NEXT: [[B:%.*]] = call i101 @bar(i101 0)
+; CHECK-NEXT: ret i101 undef
+;
+ %x = icmp eq i101 %A, 0
+ br i1 %x, label %T, label %F
T:
- %B = call i101 @bar(i101 0)
- ret i101 0
+ %B = call i101 @bar(i101 0)
+ ret i101 0
F: ; unreachable
- %C = call i101 @bar(i101 1)
- ret i101 %C
+ %C = call i101 @bar(i101 1)
+ ret i101 %C
}
define i101 @foo() {
- %X = call i101 @bar(i101 0)
- ret i101 %X
+; CHECK-LABEL: define i101 @foo() {
+; CHECK-NEXT: [[X:%.*]] = call i101 @bar(i101 0)
+; CHECK-NEXT: ret i101 0
+;
+ %X = call i101 @bar(i101 0)
+ ret i101 %X
}
diff --git a/llvm/test/Transforms/SCCP/ipsccp-clear-returned.ll b/llvm/test/Transforms/SCCP/ipsccp-clear-returned.ll
index e5bd5d5973ed3..64bc3dbdbb5f3 100644
--- a/llvm/test/Transforms/SCCP/ipsccp-clear-returned.ll
+++ b/llvm/test/Transforms/SCCP/ipsccp-clear-returned.ll
@@ -1,36 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
+
; if IPSCCP determines a function returns undef,
; then the "returned" attribute of input arguments
; should be cleared.
-; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
define i32 @main() {
-; CHECK-LABEL: @main
+; CHECK-LABEL: define i32 @main() {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: [[CALL:%.*]] = call i32 @func_return_undef(i32 1)
+; CHECK-NEXT: ret i32 1
+;
entry:
-; CHECK-NEXT: entry:
%call = call i32 @func_return_undef(i32 returned 1)
-; CHECK: call i32 @func_return_undef(i32 1)
-; CHECK-NOT: returned
ret i32 %call
-; CHECK: ret i32 1
}
define internal i32 @func_return_undef(i32 returned %arg) {
-; CHECK: {{define.*@func_return_undef}}
-; CHECK-NOT: returned
+; CHECK-LABEL: define internal i32 @func_return_undef(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: ret i32 undef
+;
entry:
-; CHECK-NEXT: entry:
-; CHECK-NEXT: {{ret.*undef}}
ret i32 %arg
}
-
; The only case that users of zapped functions are non-call site
; users is that they are blockaddr users. Skip them because we
; want to remove the returned attribute for call sites
-
-; CHECK: {{define.*@blockaddr_user}}
-; CHECK-NOT: returned
define internal i32 @blockaddr_user(i1 %c, i32 returned %d) {
+; CHECK-LABEL: define internal i32 @blockaddr_user(
+; CHECK-SAME: i1 [[C:%.*]], i32 [[D:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br i1 [[C]], label %[[BB1:.*]], label %[[BB2:.*]]
+; CHECK: [[BB1]]:
+; CHECK-NEXT: br label %[[BRANCH_BLOCK:.*]]
+; CHECK: [[BB2]]:
+; CHECK-NEXT: br label %[[BRANCH_BLOCK]]
+; CHECK: [[BRANCH_BLOCK]]:
+; CHECK-NEXT: [[ADDR:%.*]] = phi ptr [ blockaddress(@blockaddr_user, %[[TARGET1:.*]]), %[[BB1]] ], [ blockaddress(@blockaddr_user, %[[TARGET2:.*]]), %[[BB2]] ]
+; CHECK-NEXT: indirectbr ptr [[ADDR]], [label %[[TARGET1]], label %target2]
+; CHECK: [[TARGET1]]:
+; CHECK-NEXT: br label %[[TARGET2]]
+; CHECK: [[TARGET2]]:
+; CHECK-NEXT: ret i32 undef
+;
entry:
br i1 %c, label %bb1, label %bb2
@@ -47,16 +62,16 @@ branch.block:
target1:
br label %target2
-; CHECK: ret i32 undef
target2:
ret i32 %d
}
define i32 @call_blockaddr_user(i1 %c) {
; CHECK-LABEL: define i32 @call_blockaddr_user(
-; CHECK-NEXT: %r = call i32 @blockaddr_user(i1 %c
-; CHECK-NOT: returned
-; CHECK-NEXT: ret i32 10
+; CHECK-SAME: i1 [[C:%.*]]) {
+; CHECK-NEXT: [[R:%.*]] = call i32 @blockaddr_user(i1 [[C]], i32 10)
+; CHECK-NEXT: ret i32 10
+;
%r = call i32 @blockaddr_user(i1 %c, i32 returned 10)
ret i32 %r
}
diff --git a/llvm/test/Transforms/SCCP/ipsccp-noundef.ll b/llvm/test/Transforms/SCCP/ipsccp-noundef.ll
index a79ef83162d19..2f7eb725a4f41 100644
--- a/llvm/test/Transforms/SCCP/ipsccp-noundef.ll
+++ b/llvm/test/Transforms/SCCP/ipsccp-noundef.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
@g = external global i8
diff --git a/llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll b/llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
index 9ceb8c5606cb1..62ef2294cb2c6 100644
--- a/llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ b/llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -1,12 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; Basic test to check that DominatorTreeAnalysis is preserved by IPSCCP and
; the following analysis can re-use it. The test contains two trivial functions
; IPSCCP can simplify, so we can test the case where IPSCCP makes changes.
; RUN: opt -disable-verify -debug-pass-manager \
; RUN: -passes='function(require<domtree>,require<postdomtree>),ipsccp,function(require<domtree>,require<postdomtree>)' -S %s 2>&1 \
-; RUN: | FileCheck -check-prefixes='IR,NEW-PM' %s
+; RUN: | FileCheck -check-prefixes=IR,NEW-PM %s
-; RUN: opt -passes='function(require<postdomtree>),ipsccp,function(verify<domtree>)' -S %s | FileCheck -check-prefixes='IR' %s
+; RUN: opt -passes='function(require<postdomtree>),ipsccp,function(verify<domtree>)' -S %s | FileCheck -check-prefixes=IR %s
; NEW-PM: Running analysis: DominatorTreeAnalysis on f1
; NEW-PM: Running analysis: PostDominatorTreeAnalysis on f1
@@ -17,18 +18,15 @@
; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f2
; NEW-PM-NOT: Running analysis: AssumptionAnalysis
-; IR-LABEL: @f1
-; IR-LABEL: entry:
-; IR-NEXT: br label %bb2
-; IR-LABEL: bb2:
-; IR-NEXT: undef
-
-; IR-LABEL: @f2
-; IR-NOT: icmp
-; IR: br label %bbtrue
-; IR-LABEL: bbtrue:
-; IR-NEXT: ret i32 0
+
define internal i32 @f1() readnone {
+; IR-LABEL: define internal i32 @f1(
+; IR-SAME: ) #[[ATTR0:[0-9]+]] {
+; IR-NEXT: [[ENTRY:.*:]]
+; IR-NEXT: br label %[[BB2:.*]]
+; IR: [[BB2]]:
+; IR-NEXT: ret i32 undef
+;
entry:
br i1 false, label %bb1, label %bb2
bb1:
@@ -38,6 +36,13 @@ bb2:
}
define i32 @f2(i32 %n) {
+; IR-LABEL: define i32 @f2(
+; IR-SAME: i32 [[N:%.*]]) {
+; IR-NEXT: [[I:%.*]] = call i32 @f1()
+; IR-NEXT: br label %[[BBTRUE:.*]]
+; IR: [[BBTRUE]]:
+; IR-NEXT: ret i32 0
+;
%i = call i32 @f1()
%cmp = icmp eq i32 %i, 10
br i1 %cmp, label %bbtrue, label %bbfalse
@@ -49,3 +54,5 @@ bbfalse:
%res = add i32 %n, %i
ret i32 %res
}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; NEW-PM: {{.*}}
diff --git a/llvm/test/Transforms/SCCP/range-and-ip.ll b/llvm/test/Transforms/SCCP/range-and-ip.ll
index 7caea5d2cc330..87646857c6546 100644
--- a/llvm/test/Transforms/SCCP/range-and-ip.ll
+++ b/llvm/test/Transforms/SCCP/range-and-ip.ll
@@ -1,18 +1,19 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=ipsccp %s | FileCheck %s
; Make sure IPSCCP does not assume %r < 256 for @f1. Undef is passed at a call
; site, which won't be eliminated.
define i1 @constant_and_undef(i64 %a) {
-; CHECK-LABEL: @constant_and_undef(
+; CHECK-LABEL: define i1 @constant_and_undef(
+; CHECK-SAME: i64 [[A:%.*]]) {
; CHECK-NEXT: [[C_1:%.*]] = call i1 @f1(i64 undef)
-; CHECK-NEXT: br label [[BB1:%.*]]
-; CHECK: bb1:
+; CHECK-NEXT: br label %[[BB1:.*]]
+; CHECK: [[BB1]]:
; CHECK-NEXT: [[C_2:%.*]] = call i1 @f1(i64 10)
-; CHECK-NEXT: br label [[BB2:%.*]]
-; CHECK: bb2:
-; CHECK-NEXT: [[RANGE:%.*]] = and i64 [[A:%.*]], 255
+; CHECK-NEXT: br label %[[BB2:.*]]
+; CHECK: [[BB2]]:
+; CHECK-NEXT: [[RANGE:%.*]] = and i64 [[A]], 255
; CHECK-NEXT: [[C_3:%.*]] = call i1 @f1(i64 [[RANGE]])
; CHECK-NEXT: ret i1 true
;
@@ -34,8 +35,9 @@ bb2:
declare void @sideeffect(i1, i64 %a)
define internal i1 @f1(i64 %r) {
-; CHECK-LABEL: define {{.*}} @f1(
-; CHECK-NEXT: call void @sideeffect(i1 true, i64 [[R:%.*]])
+; CHECK-LABEL: define internal i1 @f1(
+; CHECK-SAME: i64 [[R:%.*]]) {
+; CHECK-NEXT: call void @sideeffect(i1 true, i64 [[R]])
; CHECK-NEXT: ret i1 undef
;
%c = icmp ult i64 %r, 256
diff --git a/llvm/test/Transforms/SCCP/solve-after-each-resolving-undefs-for-function.ll b/llvm/test/Transforms/SCCP/solve-after-each-resolving-undefs-for-function.ll
index 130a96994a32f..0d3e210aa9cf8 100644
--- a/llvm/test/Transforms/SCCP/solve-after-each-resolving-undefs-for-function.ll
+++ b/llvm/test/Transforms/SCCP/solve-after-each-resolving-undefs-for-function.ll
@@ -1,9 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
-; CHECK-LABEL: @testf(
-; CHECK: ret i32 undef
;
define internal i32 @testf(i1 %c) {
+; CHECK-LABEL: define internal i32 @testf(
+; CHECK-SAME: i1 [[C:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br i1 [[C]], label %[[IF_COND:.*]], label %[[IF_END:.*]]
+; CHECK: [[IF_COND]]:
+; CHECK-NEXT: unreachable
+; CHECK: [[IF_END]]:
+; CHECK-NEXT: ret i32 undef
+;
entry:
br i1 %c, label %if.cond, label %if.end
@@ -17,10 +25,18 @@ if.end: ; preds = %if.then1, %entry
ret i32 10
}
-; CHECK-LABEL: @test1(
-; CHECK: ret i32 undef
;
define internal i32 @test1(i1 %c) {
+; CHECK-LABEL: define internal i32 @test1(
+; CHECK-SAME: i1 [[C:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br label %[[IF_THEN:.*]]
+; CHECK: [[IF_THEN]]:
+; CHECK-NEXT: [[CALL:%.*]] = call i32 @testf(i1 [[C]])
+; CHECK-NEXT: br label %[[RET1:.*]]
+; CHECK: [[RET1]]:
+; CHECK-NEXT: ret i32 undef
+;
entry:
br label %if.then
@@ -36,11 +52,13 @@ ret2: ; preds = %if.then, %entry
ret i32 0
}
-; CHECK-LABEL: @main(
-; CHECK-NEXT: %res = call i32 @test1(
-; CHECK-NEXT: ret i32 99
;
define i32 @main(i1 %c) {
+; CHECK-LABEL: define i32 @main(
+; CHECK-SAME: i1 [[C:%.*]]) {
+; CHECK-NEXT: [[RES:%.*]] = call i32 @test1(i1 [[C]])
+; CHECK-NEXT: ret i32 99
+;
%res = call i32 @test1(i1 %c)
ret i32 %res
}
diff --git a/llvm/test/Transforms/SCCP/struct-arg-resolve-undefs.ll b/llvm/test/Transforms/SCCP/struct-arg-resolve-undefs.ll
index 7ac29b8a9a8df..f01ec6bb28093 100644
--- a/llvm/test/Transforms/SCCP/struct-arg-resolve-undefs.ll
+++ b/llvm/test/Transforms/SCCP/struct-arg-resolve-undefs.ll
@@ -1,12 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes=ipsccp -S %s | FileCheck %s
%struct.S = type { i32 }
define void @main() {
-; CHECK-LABEL: void @main() {
-; CHECK-NEXT: %r = call i32 @f(%struct.S { i32 100 })
+; CHECK-LABEL: define void @main() {
+; CHECK-NEXT: [[R:%.*]] = call i32 @f([[STRUCT_S:%.*]] { i32 100 })
; CHECK-NEXT: call void @do_report(i32 123)
+; CHECK-NEXT: ret void
+;
%r = call i32 @f(%struct.S { i32 100 })
call void @do_report(i32 %r)
ret void
@@ -15,11 +18,19 @@ define void @main() {
declare void @do_report(i32)
define internal i32 @f(%struct.S %s.coerce) {
-; CHECK-LABEL: define internal i32 @f(%struct.S %s.coerce)
-; CHECK-LABEL: entry:
-; CHECK-NEXT: %call = call i8 @lsh(i8 1, i32 100)
-; CHECK-LABEL: if.end:
-; CHECK-NEXT: ret i32 undef
+; CHECK-LABEL: define internal i32 @f(
+; CHECK-SAME: [[STRUCT_S:%.*]] [[S_COERCE:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT: [[CALL:%.*]] = call i8 @lsh(i8 1, i32 100)
+; CHECK-NEXT: br label %[[FOR_COND:.*]]
+; CHECK: [[FOR_COND]]:
+; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]], %[[FOR_COND]] ]
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], 1
+; CHECK-NEXT: [[INC]] = add nsw i32 [[I_0]], 1
+; CHECK-NEXT: br i1 [[CMP]], label %[[FOR_COND]], label %[[IF_END:.*]]
+; CHECK: [[IF_END]]:
+; CHECK-NEXT: ret i32 undef
+;
entry:
%ev = extractvalue %struct.S %s.coerce, 0
%call = call i8 @lsh(i8 1, i32 %ev)
@@ -37,6 +48,11 @@ if.end: ; preds = %for.cond, %entry
}
define internal i8 @lsh(i8 %l, i32 %r) {
+; CHECK-LABEL: define internal i8 @lsh(
+; CHECK-SAME: i8 [[L:%.*]], i32 [[R:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: ret i8 undef
+;
entry:
%conv = sext i8 %l to i32
%cmp = icmp slt i32 %conv, 0
More information about the llvm-commits
mailing list