1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4
5define internal i32 @testf(i1 %c) {
6; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
7; CGSCC-LABEL: define {{[^@]+}}@testf
8; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR0:[0-9]+]] {
9; CGSCC-NEXT:  entry:
10; CGSCC-NEXT:    br i1 [[C]], label [[IF_COND:%.*]], label [[IF_END:%.*]]
11; CGSCC:       if.cond:
12; CGSCC-NEXT:    unreachable
13; CGSCC:       if.then:
14; CGSCC-NEXT:    unreachable
15; CGSCC:       if.end:
16; CGSCC-NEXT:    ret i32 10
17;
18entry:
19  br i1 %c, label %if.cond, label %if.end
20
21if.cond:
22  br i1 undef, label %if.then, label %if.end
23
24if.then:                                          ; preds = %entry, %if.then
25  ret i32 11
26
27if.end:                                          ; preds = %if.then1, %entry
28  ret i32 10
29}
30
31define internal i32 @test1(i1 %c) {
32; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
33; CGSCC-LABEL: define {{[^@]+}}@test1
34; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] {
35; CGSCC-NEXT:  entry:
36; CGSCC-NEXT:    br label [[IF_THEN:%.*]]
37; CGSCC:       if.then:
38; CGSCC-NEXT:    [[CALL:%.*]] = call i32 @testf(i1 noundef [[C]]) #[[ATTR2:[0-9]+]]
39; CGSCC-NEXT:    [[RES:%.*]] = icmp eq i32 [[CALL]], 10
40; CGSCC-NEXT:    br i1 [[RES]], label [[RET1:%.*]], label [[RET2:%.*]]
41; CGSCC:       ret1:
42; CGSCC-NEXT:    ret i32 99
43; CGSCC:       ret2:
44; CGSCC-NEXT:    ret i32 0
45;
46entry:
47  br label %if.then
48
49if.then:                                          ; preds = %entry, %if.then
50  %call = call i32 @testf(i1 %c)
51  %res = icmp eq i32 %call, 10
52  br i1 %res, label %ret1, label %ret2
53
54ret1:                                           ; preds = %if.then, %entry
55  ret i32 99
56
57ret2:                                           ; preds = %if.then, %entry
58  ret i32 0
59}
60
61define i32 @main(i1 %c) {
62; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
63; TUNIT-LABEL: define {{[^@]+}}@main
64; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {
65; TUNIT-NEXT:    ret i32 99
66;
67; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
68; CGSCC-LABEL: define {{[^@]+}}@main
69; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
70; CGSCC-NEXT:    [[RES:%.*]] = call noundef i32 @test1(i1 [[C]]) #[[ATTR2]]
71; CGSCC-NEXT:    ret i32 [[RES]]
72;
73  %res = call i32 @test1(i1 %c)
74  ret i32 %res
75}
76;.
77; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
78;.
79; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
80; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
81; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }
82;.
83;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
84; CHECK: {{.*}}
85