xref: /llvm-project/llvm/test/Transforms/Util/assume-builder-counter.ll (revision d46e37348ec3f8054b10bcbbe7c11149d7f61031)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2; REQUIRES: asserts
3
4; RUN: opt -passes='assume-builder,verify' --enable-knowledge-retention --debug-counter=assume-builder-counter=5 -S %s | FileCheck %s --check-prefixes=COUNTER1
5; RUN: opt -passes='assume-builder,verify' --enable-knowledge-retention --debug-counter=assume-builder-counter=1-3 -S %s | FileCheck %s --check-prefixes=COUNTER2
6; RUN: opt -passes='assume-builder,verify' --enable-knowledge-retention --debug-counter=assume-builder-counter=2-202 -S %s | FileCheck %s --check-prefixes=COUNTER3
7
8target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9
10declare void @func(ptr, ptr)
11declare void @func_cold(ptr) cold willreturn nounwind
12declare void @func_strbool(ptr) "no-jump-tables"
13declare void @func_many(ptr) "no-jump-tables" nounwind "less-precise-fpmad" willreturn norecurse
14declare void @func_argattr(ptr align 8, ptr nonnull) nounwind
15declare void @func_argattr2(ptr noundef align 8, ptr noundef nonnull) nounwind
16declare void @may_throw()
17
18define void @test(ptr %P, ptr %P1, ptr %P2, ptr %P3) {
19; COUNTER1-LABEL: define {{[^@]+}}@test
20; COUNTER1-SAME: (ptr [[P:%.*]], ptr [[P1:%.*]], ptr [[P2:%.*]], ptr [[P3:%.*]]) {
21; COUNTER1-NEXT:    call void @func(ptr nonnull dereferenceable(16) [[P]], ptr null)
22; COUNTER1-NEXT:    call void @func(ptr dereferenceable(12) [[P1]], ptr nonnull [[P]])
23; COUNTER1-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]]) [[ATTR5:#.*]]
24; COUNTER1-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]])
25; COUNTER1-NEXT:    call void @func(ptr [[P1]], ptr [[P]])
26; COUNTER1-NEXT:    call void @func_strbool(ptr [[P1]])
27; COUNTER1-NEXT:    call void @func(ptr dereferenceable(32) [[P]], ptr dereferenceable(8) [[P]])
28; COUNTER1-NEXT:    call void @func_many(ptr align 8 [[P1]])
29; COUNTER1-NEXT:    call void @llvm.assume(i1 true) [ "noundef"(ptr [[P1]]), "align"(ptr [[P1]], i64 8) ]
30; COUNTER1-NEXT:    call void @func_many(ptr noundef align 8 [[P1]])
31; COUNTER1-NEXT:    call void @func_argattr(ptr [[P2]], ptr [[P3]])
32; COUNTER1-NEXT:    call void @func_argattr2(ptr [[P2]], ptr [[P3]])
33; COUNTER1-NEXT:    call void @func(ptr nonnull [[P1]], ptr nonnull [[P]])
34; COUNTER1-NEXT:    call void @func(ptr noundef nonnull [[P1]], ptr noundef nonnull [[P]])
35; COUNTER1-NEXT:    ret void
36;
37; COUNTER2-LABEL: define {{[^@]+}}@test
38; COUNTER2-SAME: (ptr [[P:%.*]], ptr [[P1:%.*]], ptr [[P2:%.*]], ptr [[P3:%.*]]) {
39; COUNTER2-NEXT:    call void @func(ptr nonnull dereferenceable(16) [[P]], ptr null)
40; COUNTER2-NEXT:    call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[P1]], i64 12) ]
41; COUNTER2-NEXT:    call void @func(ptr dereferenceable(12) [[P1]], ptr nonnull [[P]])
42; COUNTER2-NEXT:    call void @llvm.assume(i1 true) [ "cold"() ]
43; COUNTER2-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]]) [[ATTR5:#.*]]
44; COUNTER2-NEXT:    call void @llvm.assume(i1 true) [ "cold"() ]
45; COUNTER2-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]])
46; COUNTER2-NEXT:    call void @func(ptr [[P1]], ptr [[P]])
47; COUNTER2-NEXT:    call void @func_strbool(ptr [[P1]])
48; COUNTER2-NEXT:    call void @func(ptr dereferenceable(32) [[P]], ptr dereferenceable(8) [[P]])
49; COUNTER2-NEXT:    call void @func_many(ptr align 8 [[P1]])
50; COUNTER2-NEXT:    call void @func_many(ptr noundef align 8 [[P1]])
51; COUNTER2-NEXT:    call void @func_argattr(ptr [[P2]], ptr [[P3]])
52; COUNTER2-NEXT:    call void @func_argattr2(ptr [[P2]], ptr [[P3]])
53; COUNTER2-NEXT:    call void @func(ptr nonnull [[P1]], ptr nonnull [[P]])
54; COUNTER2-NEXT:    call void @func(ptr noundef nonnull [[P1]], ptr noundef nonnull [[P]])
55; COUNTER2-NEXT:    ret void
56;
57; COUNTER3-LABEL: define {{[^@]+}}@test
58; COUNTER3-SAME: (ptr [[P:%.*]], ptr [[P1:%.*]], ptr [[P2:%.*]], ptr [[P3:%.*]]) {
59; COUNTER3-NEXT:    call void @func(ptr nonnull dereferenceable(16) [[P]], ptr null)
60; COUNTER3-NEXT:    call void @func(ptr dereferenceable(12) [[P1]], ptr nonnull [[P]])
61; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[P1]], i64 12), "cold"() ]
62; COUNTER3-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]]) [[ATTR5:#.*]]
63; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "cold"() ]
64; COUNTER3-NEXT:    call void @func_cold(ptr dereferenceable(12) [[P1]])
65; COUNTER3-NEXT:    call void @func(ptr [[P1]], ptr [[P]])
66; COUNTER3-NEXT:    call void @func_strbool(ptr [[P1]])
67; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[P]], i64 32) ]
68; COUNTER3-NEXT:    call void @func(ptr dereferenceable(32) [[P]], ptr dereferenceable(8) [[P]])
69; COUNTER3-NEXT:    call void @func_many(ptr align 8 [[P1]])
70; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "noundef"(ptr [[P1]]), "align"(ptr [[P1]], i64 8) ]
71; COUNTER3-NEXT:    call void @func_many(ptr noundef align 8 [[P1]])
72; COUNTER3-NEXT:    call void @func_argattr(ptr [[P2]], ptr [[P3]])
73; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "noundef"(ptr [[P2]]), "align"(ptr [[P2]], i64 8), "noundef"(ptr [[P3]]), "nonnull"(ptr [[P3]]) ]
74; COUNTER3-NEXT:    call void @func_argattr2(ptr [[P2]], ptr [[P3]])
75; COUNTER3-NEXT:    call void @func(ptr nonnull [[P1]], ptr nonnull [[P]])
76; COUNTER3-NEXT:    call void @llvm.assume(i1 true) [ "nonnull"(ptr [[P1]]), "noundef"(ptr [[P]]), "nonnull"(ptr [[P]]) ]
77; COUNTER3-NEXT:    call void @func(ptr noundef nonnull [[P1]], ptr noundef nonnull [[P]])
78; COUNTER3-NEXT:    ret void
79;
80  call void @func(ptr nonnull dereferenceable(16) %P, ptr null)
81  call void @func(ptr dereferenceable(12) %P1, ptr nonnull %P)
82  call void @func_cold(ptr dereferenceable(12) %P1) cold
83  call void @func_cold(ptr dereferenceable(12) %P1)
84  call void @func(ptr %P1, ptr %P)
85  call void @func_strbool(ptr %P1)
86  call void @func(ptr dereferenceable(32) %P, ptr dereferenceable(8) %P)
87  call void @func_many(ptr align 8 %P1)
88  call void @func_many(ptr align 8 noundef %P1)
89  call void @func_argattr(ptr %P2, ptr %P3)
90  call void @func_argattr2(ptr %P2, ptr %P3)
91  call void @func(ptr nonnull %P1, ptr nonnull %P)
92  call void @func(ptr nonnull noundef %P1, ptr nonnull noundef %P)
93  ret void
94}
95