1; RUN: llc -filetype=asm -o - -mtriple=mips-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MIPS32 %s
2; RUN: llc -filetype=asm -o - -mtriple=mipsel-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MIPS32 %s
3; RUN: llc -filetype=asm -o - -mtriple=mips64-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MIPS64 %s
4; RUN: llc -filetype=asm -o - -mtriple=mips64el-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MIPS64 %s
5
6define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
7; CHECK:       .p2align 2
8; CHECK-MIPS64-LABEL: .Lxray_sled_0:
9; CHECK-MIPS32-LABEL: $xray_sled_0:
10; CHECK-MIPS64:  b .Ltmp1
11; CHECK-MIPS32:  b $tmp1
12; CHECK-NEXT:  nop
13; CHECK-NEXT:  nop
14; CHECK-NEXT:  nop
15; CHECK-NEXT:  nop
16; CHECK-NEXT:  nop
17; CHECK-NEXT:  nop
18; CHECK-NEXT:  nop
19; CHECK-NEXT:  nop
20; CHECK-NEXT:  nop
21; CHECK-NEXT:  nop
22; CHECK-NEXT:  nop
23; CHECK-MIPS64:  nop
24; CHECK-MIPS64:  nop
25; CHECK-MIPS64:  nop
26; CHECK-MIPS64:  nop
27; CHECK-MIPS64-LABEL: .Ltmp1:
28; CHECK-MIPS32-LABEL: $tmp1:
29; CHECK-MIPS32:  addiu $25, $25, 52
30  ret i32 0
31; CHECK:       .p2align 2
32; CHECK-MIPS64-LABEL: .Lxray_sled_1:
33; CHECK-MIPS64-NEXT:   b .Ltmp2
34; CHECK-MIPS32-LABEL: $xray_sled_1:
35; CHECK-MIPS32-NEXT:   b $tmp2
36; CHECK-NEXT:  nop
37; CHECK-NEXT:  nop
38; CHECK-NEXT:  nop
39; CHECK-NEXT:  nop
40; CHECK-NEXT:  nop
41; CHECK-NEXT:  nop
42; CHECK-NEXT:  nop
43; CHECK-NEXT:  nop
44; CHECK-NEXT:  nop
45; CHECK-NEXT:  nop
46; CHECK-NEXT:  nop
47; CHECK-MIPS64:  nop
48; CHECK-MIPS64:  nop
49; CHECK-MIPS64:  nop
50; CHECK-MIPS64:  nop
51; CHECK-MIPS64-LABEL: .Ltmp2:
52; CHECK-MIPS32-LABEL: $tmp2:
53; CHECK-MIPS32:  addiu $25, $25, 52
54}
55; CHECK:             .section xray_instr_map,"ao",@progbits,foo
56; CHECK-MIPS64:      .Ltmp3:
57; CHECK-MIPS64-NEXT:   .8byte  .Lxray_sled_0-.Ltmp3
58; CHECK-MIPS64-NEXT:   .8byte  .Lfunc_begin0-(.Ltmp3+8)
59; CHECK-MIPS32:      $tmp3:
60; CHECK-MIPS32-NEXT:   .4byte  ($xray_sled_0)-($tmp3)
61; CHECK-MIPS32-NEXT:   .4byte  ($func_begin0)-(($tmp3)+4)
62
63; We test multiple returns in a single function to make sure we're getting all
64; of them with XRay instrumentation.
65define i32 @bar(i32 %i) nounwind noinline uwtable "function-instrument"="xray-always" {
66; CHECK:       .p2align 2
67; CHECK-MIPS64-LABEL: .Lxray_sled_2:
68; CHECK-MIPS64-NEXT:   b .Ltmp6
69; CHECK-MIPS32-LABEL: $xray_sled_2:
70; CHECK-MIPS32-NEXT:   b $tmp6
71; CHECK-NEXT:  nop
72; CHECK-NEXT:  nop
73; CHECK-NEXT:  nop
74; CHECK-NEXT:  nop
75; CHECK-NEXT:  nop
76; CHECK-NEXT:  nop
77; CHECK-NEXT:  nop
78; CHECK-NEXT:  nop
79; CHECK-NEXT:  nop
80; CHECK-NEXT:  nop
81; CHECK-NEXT:  nop
82; CHECK-MIPS64:  nop
83; CHECK-MIPS64:  nop
84; CHECK-MIPS64:  nop
85; CHECK-MIPS64:  nop
86; CHECK-MIPS64-LABEL: .Ltmp6:
87; CHECK-MIPS32-LABEL: $tmp6:
88; CHECK-MIPS32:  addiu $25, $25, 52
89Test:
90  %cond = icmp eq i32 %i, 0
91  br i1 %cond, label %IsEqual, label %NotEqual
92IsEqual:
93  ret i32 0
94; CHECK:       .p2align 2
95; CHECK-MIPS64-LABEL: .Lxray_sled_3:
96; CHECK-MIPS64-NEXT:   b .Ltmp7
97; CHECK-MIPS32-LABEL: $xray_sled_3:
98; CHECK-MIPS32-NEXT:   b $tmp7
99; CHECK-NEXT:  nop
100; CHECK-NEXT:  nop
101; CHECK-NEXT:  nop
102; CHECK-NEXT:  nop
103; CHECK-NEXT:  nop
104; CHECK-NEXT:  nop
105; CHECK-NEXT:  nop
106; CHECK-NEXT:  nop
107; CHECK-NEXT:  nop
108; CHECK-NEXT:  nop
109; CHECK-NEXT:  nop
110; CHECK-MIPS64:  nop
111; CHECK-MIPS64:  nop
112; CHECK-MIPS64:  nop
113; CHECK-MIPS64:  nop
114; CHECK-MIPS64-LABEL: .Ltmp7:
115; CHECK-MIPS32-LABEL: $tmp7:
116; CHECK-MIPS32:  addiu $25, $25, 52
117NotEqual:
118  ret i32 1
119; CHECK:       .p2align 2
120; CHECK-MIPS64-LABEL: .Lxray_sled_4:
121; CHECK-MIPS64-NEXT:   b .Ltmp8
122; CHECK-MIPS32-LABEL: $xray_sled_4:
123; CHECK-MIPS32-NEXT:   b $tmp8
124; CHECK-NEXT:  nop
125; CHECK-NEXT:  nop
126; CHECK-NEXT:  nop
127; CHECK-NEXT:  nop
128; CHECK-NEXT:  nop
129; CHECK-NEXT:  nop
130; CHECK-NEXT:  nop
131; CHECK-NEXT:  nop
132; CHECK-NEXT:  nop
133; CHECK-NEXT:  nop
134; CHECK-NEXT:  nop
135; CHECK-MIPS64:  nop
136; CHECK-MIPS64:  nop
137; CHECK-MIPS64:  nop
138; CHECK-MIPS64:  nop
139; CHECK-MIPS64-LABEL: .Ltmp8:
140; CHECK-MIPS32-LABEL: $tmp8:
141; CHECK-MIPS32:  addiu $25, $25, 52
142}
143; CHECK: .section xray_instr_map,{{.*}}
144; CHECK-MIPS64: .8byte  .Lxray_sled_2
145; CHECK-MIPS64: .8byte  .Lxray_sled_3
146; CHECK-MIPS64: .8byte  .Lxray_sled_4
147; CHECK-MIPS32: .4byte	($xray_sled_2)-($tmp9)
148; CHECK-MIPS32: .4byte	($xray_sled_3)-($tmp10)
149; CHECK-MIPS32: .4byte	($xray_sled_4)-($tmp11)
150