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: store i32 [[TMP0]], ptr [[P]], align 4
20 ; TUNIT-NEXT: br label [[FOR_COND1]]
22 ; TUNIT-NEXT: ret void
24 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: readwrite)
25 ; CGSCC-LABEL: define {{[^@]+}}@fn2
26 ; CGSCC-SAME: (ptr nocapture nofree nonnull align 4 dereferenceable(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR0:[0-9]+]] {
28 ; CGSCC-NEXT: br label [[IF_END:%.*]]
30 ; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
32 ; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
33 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 4
34 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 [[TMP0]]) #[[ATTR3:[0-9]+]]
35 ; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 4
36 ; CGSCC-NEXT: br label [[FOR_COND1]]
38 ; CGSCC-NEXT: ret void
43 for.cond1: ; preds = %if.end
44 br i1 %C, label %if.end, label %exit
46 if.end: ; preds = %entry, %for.cond1
47 %e.2 = phi ptr [ %P, %entry ], [ null, %for.cond1 ]
48 %0 = load i32, ptr %e.2, align 4
49 %call = call i32 @fn1(i32 %0)
50 store i32 %call, ptr %P
56 define internal i32 @fn1(i32 %p1) {
57 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
58 ; CGSCC-LABEL: define {{[^@]+}}@fn1
59 ; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {
61 ; CGSCC-NEXT: ret i32 [[P1]]
64 %tobool = icmp ne i32 %p1, 0
65 %cond = select i1 %tobool, i32 %p1, i32 %p1
69 define void @fn_no_null_opt(ptr %P, i1 %C) null_pointer_is_valid {
71 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid
72 ; TUNIT-LABEL: define {{[^@]+}}@fn_no_null_opt
73 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] {
75 ; TUNIT-NEXT: br label [[IF_END:%.*]]
77 ; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
79 ; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
80 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4294967296
81 ; TUNIT-NEXT: store i32 [[TMP0]], ptr [[P]], align 4
82 ; TUNIT-NEXT: br label [[FOR_COND1]]
84 ; TUNIT-NEXT: ret void
86 ; CGSCC: Function Attrs: nofree nosync nounwind null_pointer_is_valid
87 ; CGSCC-LABEL: define {{[^@]+}}@fn_no_null_opt
88 ; CGSCC-SAME: (ptr nocapture nofree writeonly align 4 dereferenceable_or_null(4) [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {
90 ; CGSCC-NEXT: br label [[IF_END:%.*]]
92 ; CGSCC-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
94 ; CGSCC-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
95 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4294967296
96 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) #[[ATTR3]]
97 ; CGSCC-NEXT: store i32 [[CALL]], ptr [[P]], align 4
98 ; CGSCC-NEXT: br label [[FOR_COND1]]
100 ; CGSCC-NEXT: ret void
105 for.cond1: ; preds = %if.end
106 br i1 %C, label %if.end, label %exit
108 if.end: ; preds = %entry, %for.cond1
109 %e.2 = phi ptr [ undef, %entry ], [ null, %for.cond1 ]
110 %0 = load i32, ptr %e.2, align 4
111 %call = call i32 @fn0(i32 %0)
112 store i32 %call, ptr %P
118 define internal i32 @fn0(i32 %p1) {
119 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
120 ; CGSCC-LABEL: define {{[^@]+}}@fn0
121 ; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] {
123 ; CGSCC-NEXT: ret i32 [[P1]]
126 %tobool = icmp ne i32 %p1, 0
127 %cond = select i1 %tobool, i32 %p1, i32 %p1
131 ; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind memory(argmem: readwrite) }
132 ; TUNIT: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind null_pointer_is_valid }
134 ; CGSCC: attributes #[[ATTR0]] = { nofree nosync nounwind memory(argmem: readwrite) }
135 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
136 ; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind null_pointer_is_valid }
137 ; CGSCC: attributes #[[ATTR3]] = { nofree nosync }
139 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: