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 5define dso_local i32 @visible(ptr noalias %A, ptr noalias %B) #0 { 6; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable 7; TUNIT-LABEL: define {{[^@]+}}@visible 8; TUNIT-SAME: (ptr noalias nofree readonly captures(none) [[A:%.*]], ptr noalias nofree readonly captures(none) [[B:%.*]]) #[[ATTR0:[0-9]+]] { 9; TUNIT-NEXT: entry: 10; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr noalias nofree noundef readonly align 4 captures(none) [[A]], ptr noalias nofree noundef readonly align 4 captures(none) [[B]]) #[[ATTR4:[0-9]+]] 11; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr noalias nofree noundef readonly align 4 captures(none) [[A]], ptr noalias nofree noundef readonly align 4 captures(none) [[B]]) #[[ATTR4]] 12; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] 13; TUNIT-NEXT: ret i32 [[ADD]] 14; 15; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable 16; CGSCC-LABEL: define {{[^@]+}}@visible 17; CGSCC-SAME: (ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR0:[0-9]+]] { 18; CGSCC-NEXT: entry: 19; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR6:[0-9]+]] 20; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR6]] 21; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] 22; CGSCC-NEXT: ret i32 [[ADD]] 23; 24entry: 25 %call1 = call i32 @noalias_args(ptr %A, ptr %B) 26 %call2 = call i32 @noalias_args_argmem(ptr %A, ptr %B) 27 %add = add nsw i32 %call1, %call2 28 ret i32 %add 29} 30 31define private i32 @noalias_args(ptr %A, ptr %B) #0 { 32; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable 33; TUNIT-LABEL: define {{[^@]+}}@noalias_args 34; TUNIT-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR0]] { 35; TUNIT-NEXT: entry: 36; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 37; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4 38; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]] 39; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR4]] 40; TUNIT-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]] 41; TUNIT-NEXT: ret i32 [[ADD2]] 42; 43; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable 44; CGSCC-LABEL: define {{[^@]+}}@noalias_args 45; CGSCC-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR0]] { 46; CGSCC-NEXT: entry: 47; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 48; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4 49; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]] 50; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR7:[0-9]+]] 51; CGSCC-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]] 52; CGSCC-NEXT: ret i32 [[ADD2]] 53; 54entry: 55 %0 = load i32, ptr %A, align 4 56 %1 = load i32, ptr %B, align 4 57 %add = add nsw i32 %0, %1 58 %call = call i32 @noalias_args_argmem(ptr %A, ptr %B) 59 %add2 = add nsw i32 %add, %call 60 ret i32 %add2 61} 62 63 64define internal i32 @noalias_args_argmem(ptr %A, ptr %B) #1 { 65; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable 66; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem 67; TUNIT-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR0]] { 68; TUNIT-NEXT: entry: 69; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 70; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4 71; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]] 72; TUNIT-NEXT: ret i32 [[ADD]] 73; 74; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable 75; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem 76; CGSCC-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR1:[0-9]+]] { 77; CGSCC-NEXT: entry: 78; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 79; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4 80; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]] 81; CGSCC-NEXT: ret i32 [[ADD]] 82; 83entry: 84 %0 = load i32, ptr %A, align 4 85 %1 = load i32, ptr %B, align 4 86 %add = add nsw i32 %0, %1 87 ret i32 %add 88} 89 90define dso_local i32 @visible_local(ptr %A) #0 { 91; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable 92; TUNIT-LABEL: define {{[^@]+}}@visible_local 93; TUNIT-SAME: (ptr nofree readonly captures(none) [[A:%.*]]) #[[ATTR1:[0-9]+]] { 94; TUNIT-NEXT: entry: 95; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4 96; TUNIT-NEXT: store i32 5, ptr [[B]], align 4 97; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr nofree noundef readonly align 4 captures(none) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR4]] 98; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr nofree noundef readonly align 4 captures(none) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR4]] 99; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] 100; TUNIT-NEXT: ret i32 [[ADD]] 101; 102; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable 103; CGSCC-LABEL: define {{[^@]+}}@visible_local 104; CGSCC-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]]) #[[ATTR2:[0-9]+]] { 105; CGSCC-NEXT: entry: 106; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4 107; CGSCC-NEXT: store i32 5, ptr [[B]], align 4 108; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR6]] 109; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]], ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR8:[0-9]+]] 110; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] 111; CGSCC-NEXT: ret i32 [[ADD]] 112; 113entry: 114 %B = alloca i32, align 4 115 store i32 5, ptr %B, align 4 116 %call1 = call i32 @noalias_args(ptr %A, ptr nonnull %B) 117 %call2 = call i32 @noalias_args_argmem(ptr %A, ptr nonnull %B) 118 %add = add nsw i32 %call1, %call2 119 ret i32 %add 120} 121 122define internal i32 @noalias_args_argmem_ro(ptr %A, ptr %B) #1 { 123; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) uwtable 124; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_ro 125; CGSCC-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR3:[0-9]+]] { 126; CGSCC-NEXT: [[B_PRIV:%.*]] = alloca i32, align 4 127; CGSCC-NEXT: store i32 [[TMP1]], ptr [[B_PRIV]], align 4 128; CGSCC-NEXT: [[A_PRIV:%.*]] = alloca i32, align 4 129; CGSCC-NEXT: store i32 [[TMP0]], ptr [[A_PRIV]], align 4 130; CGSCC-NEXT: [[T0:%.*]] = load i32, ptr [[A_PRIV]], align 4 131; CGSCC-NEXT: [[T1:%.*]] = load i32, ptr [[B_PRIV]], align 4 132; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[T0]], [[T1]] 133; CGSCC-NEXT: ret i32 [[ADD]] 134; 135 %t0 = load i32, ptr %A, align 4 136 %t1 = load i32, ptr %B, align 4 137 %add = add nsw i32 %t0, %t1 138 ret i32 %add 139} 140 141define i32 @visible_local_2() { 142; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 143; TUNIT-LABEL: define {{[^@]+}}@visible_local_2 144; TUNIT-SAME: () #[[ATTR2:[0-9]+]] { 145; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4 146; TUNIT-NEXT: ret i32 10 147; 148; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) 149; CGSCC-LABEL: define {{[^@]+}}@visible_local_2 150; CGSCC-SAME: () #[[ATTR4:[0-9]+]] { 151; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_ro(i32 noundef 5, i32 noundef 5) #[[ATTR9:[0-9]+]] 152; CGSCC-NEXT: ret i32 [[CALL]] 153; 154 %B = alloca i32, align 4 155 store i32 5, ptr %B, align 4 156 %call = call i32 @noalias_args_argmem_ro(ptr %B, ptr %B) 157 ret i32 %call 158} 159 160define internal i32 @noalias_args_argmem_rn(ptr %A, ptr %B) #1 { 161; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: write) uwtable 162; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem_rn 163; TUNIT-SAME: (ptr noalias nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR3:[0-9]+]] { 164; TUNIT-NEXT: ret i32 undef 165; 166; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable 167; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_rn 168; CGSCC-SAME: (ptr noalias nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR5:[0-9]+]] { 169; CGSCC-NEXT: [[T0:%.*]] = load i32, ptr [[B]], align 4 170; CGSCC-NEXT: store i32 0, ptr [[B]], align 4 171; CGSCC-NEXT: ret i32 [[T0]] 172; 173 %t0 = load i32, ptr %B, align 4 174 store i32 0, ptr %B 175 ret i32 %t0 176} 177 178define i32 @visible_local_3() { 179; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 180; TUNIT-LABEL: define {{[^@]+}}@visible_local_3 181; TUNIT-SAME: () #[[ATTR2]] { 182; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4 183; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(ptr noalias nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR5:[0-9]+]] 184; TUNIT-NEXT: ret i32 5 185; 186; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) 187; CGSCC-LABEL: define {{[^@]+}}@visible_local_3 188; CGSCC-SAME: () #[[ATTR4]] { 189; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4 190; CGSCC-NEXT: store i32 5, ptr [[B]], align 4 191; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(ptr noalias nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR10:[0-9]+]] 192; CGSCC-NEXT: ret i32 [[CALL]] 193; 194 %B = alloca i32, align 4 195 store i32 5, ptr %B, align 4 196 %call = call i32 @noalias_args_argmem_rn(ptr %B, ptr %B) 197 ret i32 %call 198} 199 200attributes #0 = { noinline nounwind uwtable willreturn } 201attributes #1 = { argmemonly noinline nounwind uwtable willreturn} 202;. 203; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable } 204; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable } 205; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 206; TUNIT: attributes #[[ATTR3]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: write) uwtable } 207; TUNIT: attributes #[[ATTR4]] = { nofree nosync nounwind memory(read) } 208; TUNIT: attributes #[[ATTR5]] = { nofree nosync nounwind willreturn memory(write) } 209;. 210; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable } 211; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable } 212; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable } 213; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) uwtable } 214; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree nosync nounwind willreturn memory(none) } 215; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable } 216; CGSCC: attributes #[[ATTR6]] = { nofree memory(read) } 217; CGSCC: attributes #[[ATTR7]] = { nofree nounwind memory(read) } 218; CGSCC: attributes #[[ATTR8]] = { nofree } 219; CGSCC: attributes #[[ATTR9]] = { nofree nosync willreturn } 220; CGSCC: attributes #[[ATTR10]] = { nofree nounwind willreturn } 221;. 222;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: 223; CHECK: {{.*}} 224