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
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 define void @fn2(ptr %P, i1 %C) {
9 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite)
10 ; TUNIT-LABEL: define {{[^@]+}}@fn2
11 ; TUNIT-SAME: (ptr nocapture nofree [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {
13 ; TUNIT-NEXT: br label [[IF_END:%.*]]
15 ; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
17 ; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
18 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 4
19 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 [[TMP0]]) #[[ATTR3:[0-9]+]]
20 ; TUNIT-NEXT: store i32 [[CALL]], ptr [[P]], align 4
21 ; TUNIT-NEXT: br label [[FOR_COND1]]
23 ; TUNIT-NEXT: ret void
25 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: readwrite)
26 ; CGSCC-LABEL: define {{[^@]+}}@fn2
27 ; CGSCC-SAME: (ptr nocapture nofree nonnull align 4 dereferenceable(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {
29 ; CGSCC-NEXT: br label [[IF_END:%.*]]
31 ; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
33 ; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
34 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 4
35 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 [[TMP0]]) #[[ATTR3:[0-9]+]]
36 ; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 4
37 ; CGSCC-NEXT: br label [[FOR_COND1]]
39 ; CGSCC-NEXT: ret void
44 for.cond1: ; preds = %if.end
45 br i1 %C, label %if.end, label %exit
47 if.end: ; preds = %entry, %for.cond1
48 %e.2 = phi ptr [ %P, %entry ], [ null, %for.cond1 ]
49 %0 = load i32, ptr %e.2, align 4
50 %call = call i32 @fn1(i32 %0)
51 store i32 %call, ptr %P
57 define internal i32 @fn1(i32 %p1) {
58 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
59 ; CHECK-LABEL: define {{[^@]+}}@fn1
60 ; CHECK-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {
62 ; CHECK-NEXT: ret i32 [[P1]]
65 %tobool = icmp ne i32 %p1, 0
66 %cond = select i1 %tobool, i32 %p1, i32 %p1
70 define void @fn_no_null_opt(ptr %P, i1 %C) null_pointer_is_valid {
72 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid
73 ; TUNIT-LABEL: define {{[^@]+}}@fn_no_null_opt
74 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {
76 ; TUNIT-NEXT: br label [[IF_END:%.*]]
78 ; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
80 ; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
81 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4294967296
82 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) #[[ATTR3]]
83 ; TUNIT-NEXT: store i32 [[CALL]], ptr [[P]], align 4
84 ; TUNIT-NEXT: br label [[FOR_COND1]]
86 ; TUNIT-NEXT: ret void
88 ; CGSCC: Function Attrs: nofree nosync nounwind null_pointer_is_valid
89 ; CGSCC-LABEL: define {{[^@]+}}@fn_no_null_opt
90 ; CGSCC-SAME: (ptr nocapture nofree writeonly align 4 dereferenceable_or_null(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {
92 ; CGSCC-NEXT: br label [[IF_END:%.*]]
94 ; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
96 ; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
97 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4294967296
98 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) #[[ATTR3]]
99 ; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 4
100 ; CGSCC-NEXT: br label [[FOR_COND1]]
102 ; CGSCC-NEXT: ret void
107 for.cond1: ; preds = %if.end
108 br i1 %C, label %if.end, label %exit
110 if.end: ; preds = %entry, %for.cond1
111 %e.2 = phi ptr [ undef, %entry ], [ null, %for.cond1 ]
112 %0 = load i32, ptr %e.2, align 4
113 %call = call i32 @fn0(i32 %0)
114 store i32 %call, ptr %P
120 define internal i32 @fn0(i32 %p1) {
121 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
122 ; CHECK-LABEL: define {{[^@]+}}@fn0
123 ; CHECK-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] {
125 ; CHECK-NEXT: ret i32 [[P1]]
128 %tobool = icmp ne i32 %p1, 0
129 %cond = select i1 %tobool, i32 %p1, i32 %p1
133 ; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind memory(argmem: readwrite) }
134 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
135 ; TUNIT: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind null_pointer_is_valid }
136 ; TUNIT: attributes #[[ATTR3]] = { nofree nosync nounwind memory(none) }
138 ; CGSCC: attributes #[[ATTR0]] = { nofree nosync nounwind memory(argmem: readwrite) }
139 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
140 ; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind null_pointer_is_valid }
141 ; CGSCC: attributes #[[ATTR3]] = { nofree nosync }