132 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; Test that we only promote arguments when the caller/callee have compatible5; function attrubtes.6 7target triple = "x86_64-unknown-linux-gnu"8 9define internal fastcc void @no_promote_avx2(ptr %arg, ptr readonly %arg1) #0 {10; CHECK: Function Attrs: inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable11; CHECK-LABEL: define {{[^@]+}}@no_promote_avx212; CHECK-SAME: (ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[ARG:%.*]], ptr noalias nofree noundef nonnull readonly align 32 captures(none) dereferenceable(32) [[ARG1:%.*]]) #[[ATTR0:[0-9]+]] {13; CHECK-NEXT: bb:14; CHECK-NEXT: [[TMP:%.*]] = load <4 x i64>, ptr [[ARG1]], align 3215; CHECK-NEXT: store <4 x i64> [[TMP]], ptr [[ARG]], align 3216; CHECK-NEXT: ret void17;18bb:19 %tmp = load <4 x i64>, ptr %arg120 store <4 x i64> %tmp, ptr %arg21 ret void22}23 24define void @no_promote(ptr %arg) #1 {25; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable26; TUNIT-LABEL: define {{[^@]+}}@no_promote27; TUNIT-SAME: (ptr nofree writeonly captures(none) [[ARG:%.*]]) #[[ATTR1:[0-9]+]] {28; TUNIT-NEXT: bb:29; TUNIT-NEXT: [[TMP:%.*]] = alloca <4 x i64>, align 3230; TUNIT-NEXT: [[TMP2:%.*]] = alloca <4 x i64>, align 3231; TUNIT-NEXT: call void @llvm.memset.p0.i64(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP]], i8 noundef 0, i64 noundef 32, i1 noundef false) #[[ATTR3:[0-9]+]]32; TUNIT-NEXT: call fastcc void @no_promote_avx2(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP2]], ptr noalias nofree noundef nonnull readonly align 32 captures(none) dereferenceable(32) [[TMP]]) #[[ATTR4:[0-9]+]]33; TUNIT-NEXT: [[TMP4:%.*]] = load <4 x i64>, ptr [[TMP2]], align 3234; TUNIT-NEXT: store <4 x i64> [[TMP4]], ptr [[ARG]], align 235; TUNIT-NEXT: ret void36;37; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) uwtable38; CGSCC-LABEL: define {{[^@]+}}@no_promote39; CGSCC-SAME: (ptr nofree noundef nonnull writeonly align 2 captures(none) dereferenceable(32) [[ARG:%.*]]) #[[ATTR1:[0-9]+]] {40; CGSCC-NEXT: bb:41; CGSCC-NEXT: [[TMP:%.*]] = alloca <4 x i64>, align 3242; CGSCC-NEXT: [[TMP2:%.*]] = alloca <4 x i64>, align 3243; CGSCC-NEXT: call void @llvm.memset.p0.i64(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP]], i8 noundef 0, i64 noundef 32, i1 noundef false) #[[ATTR3:[0-9]+]]44; CGSCC-NEXT: call fastcc void @no_promote_avx2(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP2]], ptr noalias nofree noundef nonnull readonly align 32 captures(none) dereferenceable(32) [[TMP]]) #[[ATTR4:[0-9]+]]45; CGSCC-NEXT: [[TMP4:%.*]] = load <4 x i64>, ptr [[TMP2]], align 3246; CGSCC-NEXT: store <4 x i64> [[TMP4]], ptr [[ARG]], align 247; CGSCC-NEXT: ret void48;49bb:50 %tmp = alloca <4 x i64>, align 3251 %tmp2 = alloca <4 x i64>, align 3252 call void @llvm.memset.p0.i64(ptr align 32 %tmp, i8 0, i64 32, i1 false)53 call fastcc void @no_promote_avx2(ptr %tmp2, ptr %tmp)54 %tmp4 = load <4 x i64>, ptr %tmp2, align 3255 store <4 x i64> %tmp4, ptr %arg, align 256 ret void57}58 59define internal fastcc void @promote_avx2(ptr %arg, ptr readonly %arg1) #0 {60; CHECK: Function Attrs: inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable61; CHECK-LABEL: define {{[^@]+}}@promote_avx262; CHECK-SAME: (ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[ARG:%.*]], <4 x i64> [[TMP0:%.*]]) #[[ATTR0]] {63; CHECK-NEXT: bb:64; CHECK-NEXT: [[ARG1_PRIV:%.*]] = alloca <4 x i64>, align 3265; CHECK-NEXT: store <4 x i64> [[TMP0]], ptr [[ARG1_PRIV]], align 3266; CHECK-NEXT: [[TMP:%.*]] = load <4 x i64>, ptr [[ARG1_PRIV]], align 3267; CHECK-NEXT: store <4 x i64> [[TMP]], ptr [[ARG]], align 3268; CHECK-NEXT: ret void69;70bb:71 %tmp = load <4 x i64>, ptr %arg172 store <4 x i64> %tmp, ptr %arg73 ret void74}75 76define void @promote(ptr %arg) #0 {77; TUNIT: Function Attrs: inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable78; TUNIT-LABEL: define {{[^@]+}}@promote79; TUNIT-SAME: (ptr nofree writeonly captures(none) [[ARG:%.*]]) #[[ATTR0]] {80; TUNIT-NEXT: bb:81; TUNIT-NEXT: [[TMP:%.*]] = alloca <4 x i64>, align 3282; TUNIT-NEXT: [[TMP2:%.*]] = alloca <4 x i64>, align 3283; TUNIT-NEXT: call void @llvm.memset.p0.i64(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP]], i8 noundef 0, i64 noundef 32, i1 noundef false) #[[ATTR3]]84; TUNIT-NEXT: [[TMP0:%.*]] = load <4 x i64>, ptr [[TMP]], align 3285; TUNIT-NEXT: call fastcc void @promote_avx2(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP2]], <4 x i64> [[TMP0]]) #[[ATTR4]]86; TUNIT-NEXT: [[TMP4:%.*]] = load <4 x i64>, ptr [[TMP2]], align 3287; TUNIT-NEXT: store <4 x i64> [[TMP4]], ptr [[ARG]], align 288; TUNIT-NEXT: ret void89;90; CGSCC: Function Attrs: inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable91; CGSCC-LABEL: define {{[^@]+}}@promote92; CGSCC-SAME: (ptr nofree noundef nonnull writeonly align 2 captures(none) dereferenceable(32) [[ARG:%.*]]) #[[ATTR0]] {93; CGSCC-NEXT: bb:94; CGSCC-NEXT: [[TMP:%.*]] = alloca <4 x i64>, align 3295; CGSCC-NEXT: [[TMP2:%.*]] = alloca <4 x i64>, align 3296; CGSCC-NEXT: call void @llvm.memset.p0.i64(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP]], i8 noundef 0, i64 noundef 32, i1 noundef false) #[[ATTR3]]97; CGSCC-NEXT: [[TMP0:%.*]] = load <4 x i64>, ptr [[TMP]], align 3298; CGSCC-NEXT: call fastcc void @promote_avx2(ptr noalias nofree noundef nonnull writeonly align 32 captures(none) dereferenceable(32) [[TMP2]], <4 x i64> [[TMP0]]) #[[ATTR4]]99; CGSCC-NEXT: [[TMP4:%.*]] = load <4 x i64>, ptr [[TMP2]], align 32100; CGSCC-NEXT: store <4 x i64> [[TMP4]], ptr [[ARG]], align 2101; CGSCC-NEXT: ret void102;103bb:104 %tmp = alloca <4 x i64>, align 32105 %tmp2 = alloca <4 x i64>, align 32106 call void @llvm.memset.p0.i64(ptr align 32 %tmp, i8 0, i64 32, i1 false)107 call fastcc void @promote_avx2(ptr %tmp2, ptr %tmp)108 %tmp4 = load <4 x i64>, ptr %tmp2, align 32109 store <4 x i64> %tmp4, ptr %arg, align 2110 ret void111}112 113; Function Attrs: argmemonly nounwind114declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1) #2115 116attributes #0 = { inlinehint norecurse nounwind uwtable "target-features"="+avx2" }117attributes #1 = { nounwind uwtable }118attributes #2 = { argmemonly nounwind }119;.120; TUNIT: attributes #[[ATTR0]] = { inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable "target-features"="+avx2" }121; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable }122; TUNIT: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }123; TUNIT: attributes #[[ATTR3]] = { nofree willreturn memory(write) }124; TUNIT: attributes #[[ATTR4]] = { nofree nosync nounwind willreturn }125;.126; CGSCC: attributes #[[ATTR0]] = { inlinehint mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable "target-features"="+avx2" }127; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) uwtable }128; CGSCC: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }129; CGSCC: attributes #[[ATTR3]] = { nofree willreturn memory(write) }130; CGSCC: attributes #[[ATTR4]] = { nofree nounwind willreturn }131;.132