• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -codegenprepare -S < %s | FileCheck %s
2
3target triple = "armv8m.main-none-eabi"
4
5declare i8* @f0()
6declare i8* @f1()
7
8define i8* @tail_dup() {
9; CHECK-LABEL: tail_dup
10; CHECK: tail call i8* @f0()
11; CHECK-NEXT: ret i8*
12; CHECK: tail call i8* @f1()
13; CHECK-NEXT: ret i8*
14bb0:
15  %tmp0 = tail call i8* @f0()
16  br label %return
17bb1:
18  %tmp1 = tail call i8* @f1()
19  br label %return
20return:
21  %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
22  ret i8* %retval
23}
24
25define nonnull i8* @nonnull_dup() {
26; CHECK-LABEL: nonnull_dup
27; CHECK: tail call i8* @f0()
28; CHECK-NEXT: ret i8*
29; CHECK: tail call i8* @f1()
30; CHECK-NEXT: ret i8*
31bb0:
32  %tmp0 = tail call i8* @f0()
33  br label %return
34bb1:
35  %tmp1 = tail call i8* @f1()
36  br label %return
37return:
38  %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
39  ret i8* %retval
40}
41
42define i8* @noalias_dup() {
43; CHECK-LABEL: noalias_dup
44; CHECK: tail call noalias i8* @f0()
45; CHECK-NEXT: ret i8*
46; CHECK: tail call noalias i8* @f1()
47; CHECK-NEXT: ret i8*
48bb0:
49  %tmp0 = tail call noalias i8* @f0()
50  br label %return
51bb1:
52  %tmp1 = tail call noalias i8* @f1()
53  br label %return
54return:
55  %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
56  ret i8* %retval
57}
58
59; Use inreg as a way of testing that attributes (other than nonnull and
60; noalias) disable the tailcall duplication in cgp.
61
62define inreg i8* @inreg_nodup() {
63; CHECK-LABEL: inreg_nodup
64; CHECK: tail call i8* @f0()
65; CHECK-NEXT: br label %return
66; CHECK: tail call i8* @f1()
67; CHECK-NEXT: br label %return
68bb0:
69  %tmp0 = tail call i8* @f0()
70  br label %return
71bb1:
72  %tmp1 = tail call i8* @f1()
73  br label %return
74return:
75  %retval = phi i8* [ %tmp0, %bb0 ], [ %tmp1, %bb1 ]
76  ret i8* %retval
77}
78