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
7%struct.test.b = type { i32, i32 }
8%struct.test.a = type { %struct.test.b, i32, i8*}
9
10define void @foo(i8* %ptr) {
11; IS__TUNIT____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
12; IS__TUNIT____-LABEL: define {{[^@]+}}@foo
13; IS__TUNIT____-SAME: (i8* nocapture nofree readnone [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
14; IS__TUNIT____-NEXT:  entry:
15; IS__TUNIT____-NEXT:    [[TMP0:%.*]] = alloca [[STRUCT_TEST_A:%.*]], align 8
16; IS__TUNIT____-NEXT:    br label [[CALL_BR:%.*]]
17; IS__TUNIT____:       call.br:
18; IS__TUNIT____-NEXT:    [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], %struct.test.a* [[TMP0]], i64 0, i32 2
19; IS__TUNIT____-NEXT:    tail call void @bar(%struct.test.a* noalias nocapture nofree noundef nonnull readonly byval([[STRUCT_TEST_A]]) align 8 dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
20; IS__TUNIT____-NEXT:    ret void
21;
22; IS__CGSCC____: Function Attrs: nofree nosync nounwind readnone willreturn
23; IS__CGSCC____-LABEL: define {{[^@]+}}@foo
24; IS__CGSCC____-SAME: (i8* nocapture nofree writeonly [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
25; IS__CGSCC____-NEXT:  entry:
26; IS__CGSCC____-NEXT:    [[TMP0:%.*]] = alloca [[STRUCT_TEST_A:%.*]], align 8
27; IS__CGSCC____-NEXT:    br label [[CALL_BR:%.*]]
28; IS__CGSCC____:       call.br:
29; IS__CGSCC____-NEXT:    [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], %struct.test.a* [[TMP0]], i64 0, i32 2
30; IS__CGSCC____-NEXT:    store i8* [[PTR]], i8** [[TMP1]], align 8
31; IS__CGSCC____-NEXT:    tail call void @bar(%struct.test.a* noalias nocapture nofree noundef nonnull readnone byval([[STRUCT_TEST_A]]) align 8 dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
32; IS__CGSCC____-NEXT:    ret void
33;
34entry:
35  %0 = alloca %struct.test.a, align 8
36  br label %call.br
37
38call.br:
39  %1 = getelementptr inbounds %struct.test.a, %struct.test.a* %0, i64 0, i32 2
40  store i8* %ptr, i8** %1
41  tail call void @bar(%struct.test.a* noundef byval(%struct.test.a) align 8 %0)
42  ret void
43}
44
45define void @bar(%struct.test.a* noundef byval(%struct.test.a) align 8 %dev) {
46; CHECK: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
47; CHECK-LABEL: define {{[^@]+}}@bar
48; CHECK-SAME: (%struct.test.a* noalias nocapture nofree noundef nonnull writeonly byval([[STRUCT_TEST_A:%.*]]) align 8 dereferenceable(24) [[DEV:%.*]]) #[[ATTR1:[0-9]+]] {
49; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], %struct.test.a* [[DEV]], i64 0, i32 0
50; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_TEST_B:%.*]], %struct.test.b* [[TMP1]], i64 0, i32 1
51; CHECK-NEXT:    store i32 1, i32* [[TMP2]], align 4
52; CHECK-NEXT:    ret void
53;
54  %1 = getelementptr inbounds %struct.test.a, %struct.test.a* %dev, i64 0, i32 0
55  %2 = getelementptr inbounds %struct.test.b, %struct.test.b* %1, i64 0, i32 1
56  store i32 1, i32* %2
57  ret void
58}
59;.
60; IS__TUNIT____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
61; IS__TUNIT____: attributes #[[ATTR1]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
62; IS__TUNIT____: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn writeonly }
63;.
64; IS__CGSCC____: attributes #[[ATTR0]] = { nofree nosync nounwind readnone willreturn }
65; IS__CGSCC____: attributes #[[ATTR1]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
66; IS__CGSCC____: attributes #[[ATTR2]] = { nounwind willreturn writeonly }
67;.
68