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.ss = type { i32, i64 }
7 ; Don't drop 'byval' on %X here.
8 define internal i32 @f(ptr byval(%struct.ss) %b, ptr byval(i32) %X, i32 %i) 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:%.*]], i32 [[TMP2:%.*]]) #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[X_PRIV:%.*]] = alloca i32, align 4
15 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[X_PRIV]], align 4
16 ; CHECK-NEXT: [[B_PRIV:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
17 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B_PRIV]], align 4
18 ; CHECK-NEXT: [[B_PRIV_B4:%.*]] = getelementptr i8, ptr [[B_PRIV]], i64 4
19 ; CHECK-NEXT: store i64 [[TMP1]], ptr [[B_PRIV_B4]], align 4
20 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[B_PRIV]], align 8
21 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP1]], 1
22 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[B_PRIV]], align 8
23 ; CHECK-NEXT: store i32 0, ptr [[X_PRIV]], align 4
24 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[X_PRIV]], align 4
25 ; CHECK-NEXT: [[A:%.*]] = add i32 [[L]], [[TMP2]]
26 ; CHECK-NEXT: ret i32 [[A]]
30 %tmp1 = load i32, ptr %b, align 4
31 %tmp2 = add i32 %tmp1, 1
32 store i32 %tmp2, ptr %b, align 4
36 %a = add i32 %l, %tmp2
40 ; Also make sure we don't drop the call zeroext attribute.
41 define i32 @test(ptr %X) {
43 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
44 ; TUNIT-LABEL: define {{[^@]+}}@test
45 ; TUNIT-SAME: (ptr nocapture nofree nonnull readonly [[X:%.*]]) #[[ATTR1:[0-9]+]] {
47 ; TUNIT-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
48 ; TUNIT-NEXT: store i32 1, ptr [[S]], align 8
49 ; TUNIT-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
50 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[S]], align 8
51 ; TUNIT-NEXT: [[S_B4:%.*]] = getelementptr i8, ptr [[S]], i64 4
52 ; TUNIT-NEXT: [[TMP1:%.*]] = load i64, ptr [[S_B4]], align 8
53 ; TUNIT-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4
54 ; TUNIT-NEXT: [[C:%.*]] = call i32 @f(i32 [[TMP0]], i64 [[TMP1]], i32 [[TMP2]]) #[[ATTR2:[0-9]+]]
55 ; TUNIT-NEXT: ret i32 [[C]]
57 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite)
58 ; CGSCC-LABEL: define {{[^@]+}}@test
59 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[X:%.*]]) #[[ATTR1:[0-9]+]] {
61 ; CGSCC-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8
62 ; CGSCC-NEXT: [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
63 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4
64 ; CGSCC-NEXT: [[C:%.*]] = call i32 @f(i32 noundef 1, i64 noundef 2, i32 [[TMP0]]) #[[ATTR2:[0-9]+]]
65 ; CGSCC-NEXT: ret i32 [[C]]
68 %S = alloca %struct.ss
69 store i32 1, ptr %S, align 8
70 %tmp4 = getelementptr %struct.ss, ptr %S, i32 0, i32 1
71 store i64 2, ptr %tmp4, align 4
73 %c = call i32 @f(ptr byval(%struct.ss) %S, ptr byval(i32) %X, i32 zeroext 0)
78 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
79 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
80 ; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn }
82 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
83 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) }
84 ; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }