1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=3 -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=3 -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
7%struct.ss = type { i32, i64 }
8
9define internal void @f(%struct.ss* byval(%struct.ss)  %b, i32* byval(i32) %X) nounwind  {
10; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
11; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f
12; IS__CGSCC_OPM-SAME: (%struct.ss* noalias nocapture nofree noundef nonnull byval(%struct.ss) align 8 dereferenceable(12) [[B:%.*]], i32* noalias nocapture nofree nonnull writeonly byval(i32) align 4 dereferenceable(4) [[X:%.*]]) [[ATTR0:#.*]] {
13; IS__CGSCC_OPM-NEXT:  entry:
14; IS__CGSCC_OPM-NEXT:    [[TMP:%.*]] = getelementptr [[STRUCT_SS:%.*]], %struct.ss* [[B]], i32 0, i32 0
15; IS__CGSCC_OPM-NEXT:    [[TMP1:%.*]] = load i32, i32* [[TMP]], align 8
16; IS__CGSCC_OPM-NEXT:    [[TMP2:%.*]] = add i32 [[TMP1]], 1
17; IS__CGSCC_OPM-NEXT:    store i32 [[TMP2]], i32* [[TMP]], align 8
18; IS__CGSCC_OPM-NEXT:    store i32 0, i32* [[X]], align 4
19; IS__CGSCC_OPM-NEXT:    ret void
20;
21; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
22; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f
23; IS__CGSCC_NPM-SAME: (i32 [[TMP0:%.*]], i64 [[TMP1:%.*]], i32 [[TMP2:%.*]]) [[ATTR0:#.*]] {
24; IS__CGSCC_NPM-NEXT:  entry:
25; IS__CGSCC_NPM-NEXT:    [[X_PRIV:%.*]] = alloca i32, align 4
26; IS__CGSCC_NPM-NEXT:    store i32 [[TMP2]], i32* [[X_PRIV]], align 4
27; IS__CGSCC_NPM-NEXT:    [[B_PRIV:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
28; IS__CGSCC_NPM-NEXT:    [[B_PRIV_CAST:%.*]] = bitcast %struct.ss* [[B_PRIV]] to i32*
29; IS__CGSCC_NPM-NEXT:    store i32 [[TMP0]], i32* [[B_PRIV_CAST]], align 8
30; IS__CGSCC_NPM-NEXT:    [[B_PRIV_0_1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B_PRIV]], i32 0, i32 1
31; IS__CGSCC_NPM-NEXT:    store i64 [[TMP1]], i64* [[B_PRIV_0_1]], align 4
32; IS__CGSCC_NPM-NEXT:    [[TMP:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B_PRIV]], i32 0, i32 0
33; IS__CGSCC_NPM-NEXT:    [[TMP1:%.*]] = load i32, i32* [[TMP]], align 8
34; IS__CGSCC_NPM-NEXT:    [[TMP2:%.*]] = add i32 [[TMP1]], 1
35; IS__CGSCC_NPM-NEXT:    store i32 [[TMP2]], i32* [[TMP]], align 8
36; IS__CGSCC_NPM-NEXT:    store i32 0, i32* [[X_PRIV]], align 4
37; IS__CGSCC_NPM-NEXT:    ret void
38;
39entry:
40  %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
41  %tmp1 = load i32, i32* %tmp, align 4
42  %tmp2 = add i32 %tmp1, 1
43  store i32 %tmp2, i32* %tmp, align 4
44
45  store i32 0, i32* %X
46  ret void
47}
48
49define i32 @test(i32* %X) {
50;
51; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
52; IS__TUNIT____-LABEL: define {{[^@]+}}@test
53; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 4 [[X:%.*]]) [[ATTR0:#.*]] {
54; IS__TUNIT____-NEXT:  entry:
55; IS__TUNIT____-NEXT:    [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
56; IS__TUNIT____-NEXT:    [[TMP1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
57; IS__TUNIT____-NEXT:    store i32 1, i32* [[TMP1]], align 8
58; IS__TUNIT____-NEXT:    [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
59; IS__TUNIT____-NEXT:    store i64 2, i64* [[TMP4]], align 4
60; IS__TUNIT____-NEXT:    ret i32 0
61;
62; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
63; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test
64; IS__CGSCC_OPM-SAME: (i32* nocapture nofree nonnull readnone align 4 dereferenceable(4) [[X:%.*]]) [[ATTR0]] {
65; IS__CGSCC_OPM-NEXT:  entry:
66; IS__CGSCC_OPM-NEXT:    [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
67; IS__CGSCC_OPM-NEXT:    [[TMP1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
68; IS__CGSCC_OPM-NEXT:    store i32 1, i32* [[TMP1]], align 8
69; IS__CGSCC_OPM-NEXT:    [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
70; IS__CGSCC_OPM-NEXT:    store i64 2, i64* [[TMP4]], align 4
71; IS__CGSCC_OPM-NEXT:    ret i32 0
72;
73; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn
74; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test
75; IS__CGSCC_NPM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[X:%.*]]) [[ATTR1:#.*]] {
76; IS__CGSCC_NPM-NEXT:  entry:
77; IS__CGSCC_NPM-NEXT:    [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
78; IS__CGSCC_NPM-NEXT:    [[TMP1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
79; IS__CGSCC_NPM-NEXT:    store i32 1, i32* [[TMP1]], align 8
80; IS__CGSCC_NPM-NEXT:    [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
81; IS__CGSCC_NPM-NEXT:    store i64 2, i64* [[TMP4]], align 4
82; IS__CGSCC_NPM-NEXT:    ret i32 0
83;
84entry:
85  %S = alloca %struct.ss
86  %tmp1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
87  store i32 1, i32* %tmp1, align 8
88  %tmp4 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
89  store i64 2, i64* %tmp4, align 4
90  call void @f(%struct.ss* byval(%struct.ss) %S, i32* byval(i32) %X)
91  ret i32 0
92}
93