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
5 %struct.test.b = type { i32, i32 }
6 %struct.test.a = type { %struct.test.b, i32, ptr}
8 define void @foo(ptr %ptr) {
9 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
10 ; TUNIT-LABEL: define {{[^@]+}}@foo
11 ; TUNIT-SAME: (ptr nocapture nofree readnone [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
13 ; TUNIT-NEXT: [[TMP0:%.*]] = alloca [[STRUCT_TEST_A:%.*]], align 8
14 ; TUNIT-NEXT: br label [[CALL_BR:%.*]]
16 ; TUNIT-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], ptr [[TMP0]], i64 0, i32 2
17 ; TUNIT-NEXT: tail call void @bar(ptr noalias nocapture nofree noundef nonnull readonly byval([[STRUCT_TEST_A]]) align 8 dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
18 ; TUNIT-NEXT: ret void
20 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
21 ; CGSCC-LABEL: define {{[^@]+}}@foo
22 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
24 ; CGSCC-NEXT: [[TMP0:%.*]] = alloca [[STRUCT_TEST_A:%.*]], align 8
25 ; CGSCC-NEXT: br label [[CALL_BR:%.*]]
27 ; CGSCC-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], ptr [[TMP0]], i64 0, i32 2
28 ; CGSCC-NEXT: store ptr [[PTR]], ptr [[TMP1]], align 8
29 ; CGSCC-NEXT: tail call void @bar(ptr noalias nocapture nofree noundef nonnull readnone byval([[STRUCT_TEST_A]]) align 8 dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
30 ; CGSCC-NEXT: ret void
33 %0 = alloca %struct.test.a, align 8
37 %1 = getelementptr inbounds %struct.test.a, ptr %0, i64 0, i32 2
38 store ptr %ptr, ptr %1
39 tail call void @bar(ptr noundef byval(%struct.test.a) align 8 %0)
43 define void @bar(ptr noundef byval(%struct.test.a) align 8 %dev) {
44 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
45 ; CHECK-LABEL: define {{[^@]+}}@bar
46 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval([[STRUCT_TEST_A:%.*]]) align 8 dereferenceable(24) [[DEV:%.*]]) #[[ATTR1:[0-9]+]] {
47 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_B:%.*]], ptr [[DEV]], i64 0, i32 1
48 ; CHECK-NEXT: store i32 1, ptr [[TMP1]], align 4
49 ; CHECK-NEXT: ret void
51 %1 = getelementptr inbounds %struct.test.b, ptr %dev, i64 0, i32 1
56 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
57 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
58 ; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(write) }
60 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
61 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
62 ; CGSCC: attributes #[[ATTR2]] = { nofree nounwind willreturn memory(write) }