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
6 ; TUNIT-LABEL: define {{[^@]+}}@f() {
8 ; TUNIT-NEXT: [[A:%.*]] = alloca i32, align 1
9 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 1
10 ; TUNIT-NEXT: call void @g(i32 [[TMP0]])
11 ; TUNIT-NEXT: ret void
13 ; CGSCC-LABEL: define {{[^@]+}}@f() {
15 ; CGSCC-NEXT: call void @g(i32 undef)
16 ; CGSCC-NEXT: ret void
19 %a = alloca i32, align 1
24 define internal void @g(ptr %a) {
25 ; CHECK: Function Attrs: memory(readwrite, argmem: none)
26 ; CHECK-LABEL: define {{[^@]+}}@g
27 ; CHECK-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
28 ; CHECK-NEXT: [[A_PRIV:%.*]] = alloca i32, align 4
29 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[A_PRIV]], align 4
30 ; CHECK-NEXT: [[AA:%.*]] = load i32, ptr [[A_PRIV]], align 1
31 ; CHECK-NEXT: call void @z(i32 [[AA]])
32 ; CHECK-NEXT: ret void
34 %aa = load i32, ptr %a, align 1
42 ; Different alignemnt privatizable arguments
43 define internal i32 @test(ptr %X, ptr %Y) {
44 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
45 ; CGSCC-LABEL: define {{[^@]+}}@test
46 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[X:%.*]], i64 [[TMP0:%.*]]) #[[ATTR1:[0-9]+]] {
47 ; CGSCC-NEXT: [[Y_PRIV:%.*]] = alloca i64, align 8
48 ; CGSCC-NEXT: store i64 [[TMP0]], ptr [[Y_PRIV]], align 4
49 ; CGSCC-NEXT: [[A:%.*]] = load i32, ptr [[X]], align 4
50 ; CGSCC-NEXT: [[B:%.*]] = load i64, ptr [[Y_PRIV]], align 8
51 ; CGSCC-NEXT: [[C:%.*]] = add i32 [[A]], 1
52 ; CGSCC-NEXT: [[D:%.*]] = add i64 [[B]], 1
53 ; CGSCC-NEXT: [[COND:%.*]] = icmp sgt i64 [[D]], -1
54 ; CGSCC-NEXT: br i1 [[COND]], label [[RETURN1:%.*]], label [[RETURN2:%.*]]
56 ; CGSCC-NEXT: ret i32 [[C]]
58 ; CGSCC-NEXT: ret i32 [[A]]
64 %cond = icmp sgt i64 %D, -1
65 br i1 %cond, label %Return1, label %Return2
72 define internal i32 @caller(ptr %A) {
73 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
74 ; CGSCC-LABEL: define {{[^@]+}}@caller
75 ; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR2:[0-9]+]] {
76 ; CGSCC-NEXT: [[A_PRIV:%.*]] = alloca i32, align 4
77 ; CGSCC-NEXT: store i32 [[TMP0]], ptr [[A_PRIV]], align 4
78 ; CGSCC-NEXT: [[C:%.*]] = call i32 @test(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A_PRIV]], i64 noundef 1) #[[ATTR3:[0-9]+]]
79 ; CGSCC-NEXT: ret i32 [[C]]
83 %C = call i32 @test(ptr %A, ptr %B)
87 define i32 @callercaller() {
88 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
89 ; TUNIT-LABEL: define {{[^@]+}}@callercaller
90 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
91 ; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
92 ; TUNIT-NEXT: ret i32 3
94 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
95 ; CGSCC-LABEL: define {{[^@]+}}@callercaller
96 ; CGSCC-SAME: () #[[ATTR2]] {
97 ; CGSCC-NEXT: [[X:%.*]] = call i32 @caller(i32 noundef 2) #[[ATTR4:[0-9]+]]
98 ; CGSCC-NEXT: ret i32 [[X]]
102 %X = call i32 @caller(ptr %B)
106 ; TUNIT: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }
107 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
109 ; CGSCC: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }
110 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
111 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
112 ; CGSCC: attributes #[[ATTR3]] = { nofree willreturn memory(read) }
113 ; CGSCC: attributes #[[ATTR4]] = { nofree nosync willreturn }