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 5target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" 6 7%struct.ss = type { i32, i32 } 8 9; Argpromote + sroa should change this to passing the two integers by value. 10define internal i32 @f(ptr inalloca(%struct.ss) %s) { 11; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 12; CHECK-LABEL: define {{[^@]+}}@f 13; CHECK-SAME: (ptr noalias nofree noundef nonnull inalloca([[STRUCT_SS:%.*]]) align 4 captures(none) dereferenceable(8) [[S:%.*]]) #[[ATTR0:[0-9]+]] { 14; CHECK-NEXT: entry: 15; CHECK-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1 16; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[S]], align 4 17; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[F1]], align 4 18; CHECK-NEXT: [[R:%.*]] = add i32 [[A]], [[B]] 19; CHECK-NEXT: ret i32 [[R]] 20; 21entry: 22 %f1 = getelementptr %struct.ss, ptr %s, i32 0, i32 1 23 %a = load i32, ptr %s, align 4 24 %b = load i32, ptr %f1, align 4 25 %r = add i32 %a, %b 26 ret i32 %r 27} 28 29define i32 @main() { 30; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 31; TUNIT-LABEL: define {{[^@]+}}@main 32; TUNIT-SAME: () #[[ATTR1:[0-9]+]] { 33; TUNIT-NEXT: entry: 34; TUNIT-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 4 35; TUNIT-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1 36; TUNIT-NEXT: store i32 1, ptr [[S]], align 4 37; TUNIT-NEXT: store i32 2, ptr [[F1]], align 4 38; TUNIT-NEXT: [[R:%.*]] = call i32 @f(ptr noalias nofree noundef nonnull inalloca([[STRUCT_SS]]) align 4 captures(none) dereferenceable(8) [[S]]) #[[ATTR2:[0-9]+]] 39; TUNIT-NEXT: ret i32 [[R]] 40; 41; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) 42; CGSCC-LABEL: define {{[^@]+}}@main 43; CGSCC-SAME: () #[[ATTR1:[0-9]+]] { 44; CGSCC-NEXT: entry: 45; CGSCC-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 4 46; CGSCC-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1 47; CGSCC-NEXT: store i32 1, ptr [[S]], align 4 48; CGSCC-NEXT: store i32 2, ptr [[F1]], align 4 49; CGSCC-NEXT: [[R:%.*]] = call i32 @f(ptr noalias nofree noundef nonnull inalloca([[STRUCT_SS]]) align 4 captures(none) dereferenceable(8) [[S]]) #[[ATTR3:[0-9]+]] 50; CGSCC-NEXT: ret i32 [[R]] 51; 52entry: 53 %S = alloca inalloca %struct.ss 54 %f1 = getelementptr %struct.ss, ptr %S, i32 0, i32 1 55 store i32 1, ptr %S, align 4 56 store i32 2, ptr %f1, align 4 57 %r = call i32 @f(ptr inalloca(%struct.ss) %S) 58 ret i32 %r 59} 60 61; Argpromote can't promote %a because of the icmp use. 62define internal i1 @g(ptr %a, ptr inalloca(%struct.ss) %b) nounwind { 63; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 64; CGSCC-LABEL: define {{[^@]+}}@g 65; CGSCC-SAME: (ptr noalias nofree noundef nonnull readnone align 4 captures(none) dereferenceable(8) [[A:%.*]], ptr noalias nofree noundef nonnull writeonly inalloca([[STRUCT_SS:%.*]]) align 4 captures(none) dereferenceable(8) [[B:%.*]]) #[[ATTR2:[0-9]+]] { 66; CGSCC-NEXT: entry: 67; CGSCC-NEXT: ret i1 undef 68; 69entry: 70 %c = icmp eq ptr %a, %b 71 ret i1 %c 72} 73 74define i32 @test() { 75; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 76; TUNIT-LABEL: define {{[^@]+}}@test 77; TUNIT-SAME: () #[[ATTR1]] { 78; TUNIT-NEXT: entry: 79; TUNIT-NEXT: ret i32 0 80; 81; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) 82; CGSCC-LABEL: define {{[^@]+}}@test 83; CGSCC-SAME: () #[[ATTR1]] { 84; CGSCC-NEXT: entry: 85; CGSCC-NEXT: ret i32 0 86; 87entry: 88 %S = alloca inalloca %struct.ss 89 %c = call i1 @g(ptr %S, ptr inalloca(%struct.ss) %S) 90 ret i32 0 91} 92;. 93; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) } 94; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 95; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(read) } 96;. 97; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) } 98; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) } 99; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 100; CGSCC: attributes #[[ATTR3]] = { nofree willreturn memory(read) } 101;. 102