1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6
7define void @f() {
8; IS__TUNIT____-LABEL: define {{[^@]+}}@f() {
9; IS__TUNIT____-NEXT:  entry:
10; IS__TUNIT____-NEXT:    call void @g()
11; IS__TUNIT____-NEXT:    ret void
12;
13; IS__CGSCC____-LABEL: define {{[^@]+}}@f() {
14; IS__CGSCC____-NEXT:  entry:
15; IS__CGSCC____-NEXT:    [[A:%.*]] = alloca i32, align 1
16; IS__CGSCC____-NEXT:    call void @g()
17; IS__CGSCC____-NEXT:    ret void
18;
19entry:
20  %a = alloca i32, align 1
21  call void @g(i32* %a)
22  ret void
23}
24
25define internal void @g(i32* %a) {
26; CHECK-LABEL: define {{[^@]+}}@g() {
27; CHECK-NEXT:    call void @z(i32 undef)
28; CHECK-NEXT:    ret void
29;
30  %aa = load i32, i32* %a, align 1
31  call void @z(i32 %aa)
32  ret void
33}
34
35declare void @z(i32)
36
37; Test2
38; Different alignemnt privatizable arguments
39define internal i32 @test(i32* %X, i64* %Y) {
40; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
41; IS__CGSCC____-LABEL: define {{[^@]+}}@test
42; IS__CGSCC____-SAME: () #[[ATTR0:[0-9]+]] {
43; IS__CGSCC____-NEXT:    br label [[RETURN1:%.*]]
44; IS__CGSCC____:       Return1:
45; IS__CGSCC____-NEXT:    ret i32 3
46; IS__CGSCC____:       Return2:
47; IS__CGSCC____-NEXT:    unreachable
48;
49  %A = load i32, i32* %X
50  %B = load i64, i64* %Y
51  %C = add i32 %A, 1
52  %D = add i64 %B, 1
53  %cond = icmp sgt i64 %D, -1
54  br i1 %cond, label %Return1, label %Return2
55Return1:
56  ret i32 %C
57Return2:
58  ret i32 %A
59}
60
61define internal i32 @caller(i32* %A) {
62; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
63; IS__CGSCC____-LABEL: define {{[^@]+}}@caller
64; IS__CGSCC____-SAME: () #[[ATTR0]] {
65; IS__CGSCC____-NEXT:    [[B:%.*]] = alloca i64, align 8
66; IS__CGSCC____-NEXT:    ret i32 3
67;
68  %B = alloca i64
69  store i64 1, i64* %B
70  %C = call i32 @test(i32* %A, i64* %B)
71  ret i32 %C
72}
73
74define i32 @callercaller() {
75; CHECK: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
76; CHECK-LABEL: define {{[^@]+}}@callercaller
77; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
78; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
79; CHECK-NEXT:    ret i32 3
80;
81  %B = alloca i32
82  store i32 2, i32* %B
83  %X = call i32 @caller(i32* %B)
84  ret i32 %X
85}
86;.
87; CHECK: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
88;.
89