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 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
7 %struct.ss = type { i32, i32 }
9 ; Argpromote + sroa should change this to passing the two integers by value.
10 define internal i32 @f(ptr inalloca(%struct.ss) %s) {
11 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
12 ; CHECK-LABEL: define {{[^@]+}}@f
13 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull inalloca([[STRUCT_SS:%.*]]) align 4 dereferenceable(8) [[S:%.*]]) #[[ATTR0:[0-9]+]] {
15 ; CHECK-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
16 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[S]], align 4
17 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[F1]], align 4
18 ; CHECK-NEXT: [[R:%.*]] = add i32 [[A]], [[B]]
19 ; CHECK-NEXT: ret i32 [[R]]
22 %f1 = getelementptr %struct.ss, ptr %s, i32 0, i32 1
23 %a = load i32, ptr %s, align 4
24 %b = load i32, ptr %f1, align 4
30 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
31 ; TUNIT-LABEL: define {{[^@]+}}@main
32 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
34 ; TUNIT-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 4
35 ; TUNIT-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
36 ; TUNIT-NEXT: store i32 1, ptr [[S]], align 4
37 ; TUNIT-NEXT: store i32 2, ptr [[F1]], align 4
38 ; TUNIT-NEXT: [[R:%.*]] = call i32 @f(ptr noalias nocapture nofree noundef nonnull inalloca([[STRUCT_SS]]) align 4 dereferenceable(8) [[S]]) #[[ATTR2:[0-9]+]]
39 ; TUNIT-NEXT: ret i32 [[R]]
41 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
42 ; CGSCC-LABEL: define {{[^@]+}}@main
43 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
45 ; CGSCC-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 4
46 ; CGSCC-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
47 ; CGSCC-NEXT: store i32 1, ptr [[S]], align 4
48 ; CGSCC-NEXT: store i32 2, ptr [[F1]], align 4
49 ; CGSCC-NEXT: [[R:%.*]] = call i32 @f(ptr noalias nocapture nofree noundef nonnull inalloca([[STRUCT_SS]]) align 4 dereferenceable(8) [[S]]) #[[ATTR3:[0-9]+]]
50 ; CGSCC-NEXT: ret i32 [[R]]
53 %S = alloca inalloca %struct.ss
54 %f1 = getelementptr %struct.ss, ptr %S, i32 0, i32 1
55 store i32 1, ptr %S, align 4
56 store i32 2, ptr %f1, align 4
57 %r = call i32 @f(ptr inalloca(%struct.ss) %S)
61 ; Argpromote can't promote %a because of the icmp use.
62 define internal i1 @g(ptr %a, ptr inalloca(%struct.ss) %b) nounwind {
63 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
64 ; CGSCC-LABEL: define {{[^@]+}}@g
65 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull readnone align 4 dereferenceable(8) [[A:%.*]], ptr noalias nocapture nofree noundef nonnull writeonly inalloca([[STRUCT_SS:%.*]]) align 4 dereferenceable(8) [[B:%.*]]) #[[ATTR2:[0-9]+]] {
67 ; CGSCC-NEXT: ret i1 undef
70 %c = icmp eq ptr %a, %b
75 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
76 ; TUNIT-LABEL: define {{[^@]+}}@test
77 ; TUNIT-SAME: () #[[ATTR1]] {
79 ; TUNIT-NEXT: ret i32 0
81 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
82 ; CGSCC-LABEL: define {{[^@]+}}@test
83 ; CGSCC-SAME: () #[[ATTR1]] {
85 ; CGSCC-NEXT: ret i32 0
88 %S = alloca inalloca %struct.ss
89 %c = call i1 @g(ptr %S, ptr inalloca(%struct.ss) %S)
93 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
94 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
95 ; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(read) }
97 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
98 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
99 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
100 ; CGSCC: attributes #[[ATTR3]] = { nofree willreturn memory(read) }