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, i64 }
9 define internal i32 @f(ptr byval(%struct.ss) %b) nounwind {
10 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
11 ; CHECK-LABEL: define {{[^@]+}}@f
12 ; CHECK-SAME: (i32 [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[B_PRIV:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
15 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B_PRIV]], align 4
16 ; CHECK-NEXT: [[B_PRIV_B4:%.*]] = getelementptr i8, ptr [[B_PRIV]], i64 4
17 ; CHECK-NEXT: store i64 [[TMP1]], ptr [[B_PRIV_B4]], align 4
18 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_PRIV]], align 8
19 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP1]], 1
20 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[B_PRIV]], align 8
21 ; CHECK-NEXT: ret i32 [[TMP1]]
24 %tmp1 = load i32, ptr %b, align 4
25 %tmp2 = add i32 %tmp1, 1
26 store i32 %tmp2, ptr %b, align 4
31 define internal i32 @g(ptr byval(%struct.ss) align 32 %b) nounwind {
32 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
33 ; CHECK-LABEL: define {{[^@]+}}@g
34 ; CHECK-SAME: (i32 [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0]] {
36 ; CHECK-NEXT: [[B_PRIV:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
37 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B_PRIV]], align 4
38 ; CHECK-NEXT: [[B_PRIV_B4:%.*]] = getelementptr i8, ptr [[B_PRIV]], i64 4
39 ; CHECK-NEXT: store i64 [[TMP1]], ptr [[B_PRIV_B4]], align 4
40 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_PRIV]], align 32
41 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP1]], 1
42 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[B_PRIV]], align 32
43 ; CHECK-NEXT: ret i32 [[TMP2]]
46 %tmp1 = load i32, ptr %b, align 4
47 %tmp2 = add i32 %tmp1, 1
48 store i32 %tmp2, ptr %b, align 4
53 define i32 @main() nounwind {
54 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
55 ; TUNIT-LABEL: define {{[^@]+}}@main
56 ; TUNIT-SAME: () #[[ATTR0]] {
58 ; TUNIT-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
59 ; TUNIT-NEXT: store i32 1, ptr [[S]], align 32
60 ; TUNIT-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
61 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[S]], align 8
62 ; TUNIT-NEXT: [[S_B4:%.*]] = getelementptr i8, ptr [[S]], i64 4
63 ; TUNIT-NEXT: [[TMP1:%.*]] = load i64, ptr [[S_B4]], align 8
64 ; TUNIT-NEXT: [[C0:%.*]] = call i32 @f(i32 [[TMP0]], i64 [[TMP1]]) #[[ATTR1:[0-9]+]]
65 ; TUNIT-NEXT: [[TMP2:%.*]] = load i32, ptr [[S]], align 32
66 ; TUNIT-NEXT: [[S_B41:%.*]] = getelementptr i8, ptr [[S]], i64 4
67 ; TUNIT-NEXT: [[TMP3:%.*]] = load i64, ptr [[S_B41]], align 32
68 ; TUNIT-NEXT: [[C1:%.*]] = call i32 @g(i32 [[TMP2]], i64 [[TMP3]]) #[[ATTR1]]
69 ; TUNIT-NEXT: [[A:%.*]] = add i32 [[C0]], [[C1]]
70 ; TUNIT-NEXT: ret i32 [[A]]
72 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
73 ; CGSCC-LABEL: define {{[^@]+}}@main
74 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
76 ; CGSCC-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
77 ; CGSCC-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
78 ; CGSCC-NEXT: [[C0:%.*]] = call i32 @f(i32 noundef 1, i64 noundef 2) #[[ATTR2:[0-9]+]]
79 ; CGSCC-NEXT: [[C1:%.*]] = call i32 @g(i32 noundef 1, i64 noundef 2) #[[ATTR2]]
80 ; CGSCC-NEXT: [[A:%.*]] = add i32 [[C0]], [[C1]]
81 ; CGSCC-NEXT: ret i32 [[A]]
84 %S = alloca %struct.ss
85 store i32 1, ptr %S, align 8
86 %tmp4 = getelementptr %struct.ss, ptr %S, i32 0, i32 1
87 store i64 2, ptr %tmp4, align 4
88 %c0 = call i32 @f(ptr byval(%struct.ss) %S) nounwind
89 %c1 = call i32 @g(ptr byval(%struct.ss) %S) nounwind
96 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
97 ; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn }
99 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
100 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
101 ; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn }