1 ; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S < %s | FileCheck %s
3 target triple = "armv8m.main-none-eabi"
7 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
8 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind
10 define ptr @tail_dup() {
11 ; CHECK-LABEL: tail_dup
12 ; CHECK: tail call ptr @f0()
14 ; CHECK: tail call ptr @f1()
18 call void @llvm.lifetime.start.p0(i64 -1, ptr %a) nounwind
19 %tmp0 = tail call ptr @f0()
22 %tmp1 = tail call ptr @f1()
25 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
26 call void @llvm.lifetime.end.p0(i64 -1, ptr %a) nounwind
30 define nonnull ptr @nonnull_dup() {
31 ; CHECK-LABEL: nonnull_dup
32 ; CHECK: tail call ptr @f0()
34 ; CHECK: tail call ptr @f1()
37 %tmp0 = tail call ptr @f0()
40 %tmp1 = tail call ptr @f1()
43 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
47 define ptr @noalias_dup() {
48 ; CHECK-LABEL: noalias_dup
49 ; CHECK: tail call noalias ptr @f0()
51 ; CHECK: tail call noalias ptr @f1()
54 %tmp0 = tail call noalias ptr @f0()
57 %tmp1 = tail call noalias ptr @f1()
60 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
64 ; Use inreg as a way of testing that attributes (other than nonnull and
65 ; noalias) disable the tailcall duplication in cgp.
67 define inreg ptr @inreg_nodup() {
68 ; CHECK-LABEL: inreg_nodup
69 ; CHECK: tail call ptr @f0()
70 ; CHECK-NEXT: br label %return
71 ; CHECK: tail call ptr @f1()
72 ; CHECK-NEXT: br label %return
74 %tmp0 = tail call ptr @f0()
77 %tmp1 = tail call ptr @f1()
80 %retval = phi ptr [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]