xref: /llvm-project/llvm/test/tools/llvm-reduce/operands-to-args.ll (revision 1437a83491cbe4af1b452a3f862a6b609057c26d)
1; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction --delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg --match-full-lines --test-arg --check-prefix=INTERESTING --test-arg --input-file
2; RUN: FileCheck %s --input-file %t --check-prefixes=REDUCED,INTERESTING
3
4; REDUCED-LABEL: define void @func(i32 %k, ptr %Local, ptr %Global) {
5
6; Keep one reference to the original value.
7; INTERESTING: %[[LOCAL:Local[0-9]*]] = alloca i32, align 4
8; INTERESTING: store i32 42, ptr %[[LOCAL]], align 4
9; INTERESTING: store i32 42, ptr @Global, align 4
10
11; Everything else must use the function argument.
12; REDUCED: store i32 21, ptr %Local, align 4
13; REDUCED: store i32 21, ptr %Global, align 4
14; REDUCED: store i32 0, ptr %Local, align 4
15; REDUCED: store i32 0, ptr %Global, align 4
16; REDUCED: store float 0.000000e+00, ptr %Global, align 4
17
18; Do not add any arguments for %Keep and @GlobalKeep.
19; INTERESTING: %[[KEEP:LocalKeep[0-9]*]] = add i32 %k, 21
20; INTERESTING: store i32 %[[KEEP]], ptr @GlobalKeep, align 4
21
22; INTERESTING-LABEL: define void @func_caller() {
23; REDUCED:             call void @func(i32 21, ptr null, ptr null)
24
25
26@Global = global i32 42
27@GlobalKeep = global i32 42
28
29define void @func(i32 %k) {
30entry:
31  %Local = alloca i32, align 4
32
33  store i32 42, ptr %Local, align 4
34  store i32 42, ptr @Global, align 4
35
36  store i32 21, ptr %Local, align 4
37  store i32 21, ptr @Global, align 4
38
39  store i32 0, ptr %Local, align 4
40  store i32 0, ptr @Global, align 4
41
42  store float 0.000000e+00, ptr @Global, align 4
43
44  %LocalKeep = add i32 %k, 21
45  store i32 %LocalKeep, ptr @GlobalKeep, align 4
46
47  ret void
48}
49
50
51define void @func_caller() {
52entry:
53  call void @func(i32 21)
54  ret void
55}
56
57
58; Make sure to skip functions with non-direct call users
59declare void @e(ptr)
60
61; INTERESTING-LABEL: define void @g() {
62define void @g() {
63  call void @e(ptr @f)
64  ret void
65}
66
67; INTERESTING-LABEL: define void @f(ptr %a) {
68define void @f(ptr %a) {
69  %1 = load ptr, ptr %a
70  ret void
71}
72