1 ; RUN: opt -codegenprepare -S < %s | FileCheck %s
3 target triple = "armv8m.main-none-eabi"
7 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind
8 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind
10 define i8* @tail_dup() {
11 ; CHECK-LABEL: tail_dup
12 ; CHECK: tail call i8* @f0()
14 ; CHECK: tail call i8* @f1()
18 %a1 = bitcast i32* %a to i8*
19 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %a1) nounwind
20 %tmp0 = tail call i8* @f0()
23 %tmp1 = tail call i8* @f1()
26 %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
27 %a2 = bitcast i32* %a to i8*
28 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %a2) nounwind
32 define nonnull i8* @nonnull_dup() {
33 ; CHECK-LABEL: nonnull_dup
34 ; CHECK: tail call i8* @f0()
36 ; CHECK: tail call i8* @f1()
39 %tmp0 = tail call i8* @f0()
42 %tmp1 = tail call i8* @f1()
45 %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
49 define i8* @noalias_dup() {
50 ; CHECK-LABEL: noalias_dup
51 ; CHECK: tail call noalias i8* @f0()
53 ; CHECK: tail call noalias i8* @f1()
56 %tmp0 = tail call noalias i8* @f0()
59 %tmp1 = tail call noalias i8* @f1()
62 %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
66 ; Use inreg as a way of testing that attributes (other than nonnull and
67 ; noalias) disable the tailcall duplication in cgp.
69 define inreg i8* @inreg_nodup() {
70 ; CHECK-LABEL: inreg_nodup
71 ; CHECK: tail call i8* @f0()
72 ; CHECK-NEXT: br label %return
73 ; CHECK: tail call i8* @f1()
74 ; CHECK-NEXT: br label %return
76 %tmp0 = tail call i8* @f0()
79 %tmp1 = tail call i8* @f1()
82 %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]