83 lines · plain
1; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S < %s | FileCheck %s2 3target triple = "armv8m.main-none-eabi"4 5declare ptr @f0()6declare ptr @f1()7declare void @llvm.lifetime.start.p0(ptr nocapture) nounwind8declare void @llvm.lifetime.end.p0(ptr nocapture) nounwind9 10define ptr @tail_dup() {11; CHECK-LABEL: tail_dup12; CHECK: tail call ptr @f0()13; CHECK-NEXT: ret ptr14; CHECK: tail call ptr @f1()15; CHECK-NEXT: ret ptr16bb0:17 %a = alloca i3218 call void @llvm.lifetime.start.p0(ptr %a) nounwind19 %tmp0 = tail call ptr @f0()20 br label %return21bb1:22 %tmp1 = tail call ptr @f1()23 br label %return24return:25 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]26 call void @llvm.lifetime.end.p0(ptr %a) nounwind27 ret ptr %retval28}29 30define nonnull ptr @nonnull_dup() {31; CHECK-LABEL: nonnull_dup32; CHECK: tail call ptr @f0()33; CHECK-NEXT: ret ptr34; CHECK: tail call ptr @f1()35; CHECK-NEXT: ret ptr36bb0:37 %tmp0 = tail call ptr @f0()38 br label %return39bb1:40 %tmp1 = tail call ptr @f1()41 br label %return42return:43 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]44 ret ptr %retval45}46 47define ptr @noalias_dup() {48; CHECK-LABEL: noalias_dup49; CHECK: tail call noalias ptr @f0()50; CHECK-NEXT: ret ptr51; CHECK: tail call noalias ptr @f1()52; CHECK-NEXT: ret ptr53bb0:54 %tmp0 = tail call noalias ptr @f0()55 br label %return56bb1:57 %tmp1 = tail call noalias ptr @f1()58 br label %return59return:60 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]61 ret ptr %retval62}63 64; Use inreg as a way of testing that attributes (other than nonnull and65; noalias) disable the tailcall duplication in cgp.66 67define inreg ptr @inreg_nodup() {68; CHECK-LABEL: inreg_nodup69; CHECK: tail call ptr @f0()70; CHECK-NEXT: br label %return71; CHECK: tail call ptr @f1()72; CHECK-NEXT: br label %return73bb0:74 %tmp0 = tail call ptr @f0()75 br label %return76bb1:77 %tmp1 = tail call ptr @f1()78 br label %return79return:80 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]81 ret ptr %retval82}83