102 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC4 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 {{[^@]+}}@f13; 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 116; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[S]], align 417; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[F1]], align 418; 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 123 %a = load i32, ptr %s, align 424 %b = load i32, ptr %f1, align 425 %r = add i32 %a, %b26 ret i32 %r27}28 29define i32 @main() {30; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)31; TUNIT-LABEL: define {{[^@]+}}@main32; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {33; TUNIT-NEXT: entry:34; TUNIT-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 435; TUNIT-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 136; TUNIT-NEXT: store i32 1, ptr [[S]], align 437; TUNIT-NEXT: store i32 2, ptr [[F1]], align 438; 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 {{[^@]+}}@main43; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {44; CGSCC-NEXT: entry:45; CGSCC-NEXT: [[S:%.*]] = alloca inalloca [[STRUCT_SS:%.*]], align 446; CGSCC-NEXT: [[F1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 147; CGSCC-NEXT: store i32 1, ptr [[S]], align 448; CGSCC-NEXT: store i32 2, ptr [[F1]], align 449; 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.ss54 %f1 = getelementptr %struct.ss, ptr %S, i32 0, i32 155 store i32 1, ptr %S, align 456 store i32 2, ptr %f1, align 457 %r = call i32 @f(ptr inalloca(%struct.ss) %S)58 ret i32 %r59}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 {{[^@]+}}@g65; 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 undef68;69entry:70 %c = icmp eq ptr %a, %b71 ret i1 %c72}73 74define i32 @test() {75; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)76; TUNIT-LABEL: define {{[^@]+}}@test77; TUNIT-SAME: () #[[ATTR1]] {78; TUNIT-NEXT: entry:79; TUNIT-NEXT: ret i32 080;81; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)82; CGSCC-LABEL: define {{[^@]+}}@test83; CGSCC-SAME: () #[[ATTR1]] {84; CGSCC-NEXT: entry:85; CGSCC-NEXT: ret i32 086;87entry:88 %S = alloca inalloca %struct.ss89 %c = call i1 @g(ptr %S, ptr inalloca(%struct.ss) %S)90 ret i32 091}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