1; RUN: llc -mtriple=thumbv4t-eabi %s -o - | FileCheck ---check-prefix=CHECK -check-prefix=CHECK-V4T %s
2; RUN: llc -mtriple=thumbv5t-eabi %s -o - | FileCheck ---check-prefix=CHECK -check-prefix=CHECK-V5T %s
3
4@f = common global void (i32)* null, align 4
5
6; CHECK-LABEL: foo:
7define void @foo(i32 %x) {
8entry:
9  %0 = load void (i32)*, void (i32)** @f, align 4
10  tail call void %0(i32 %x)
11  ret void
12
13; CHECK: ldr [[TMP:r[0-3]]], [[F:\.[A-Z0-9_]+]]
14; CHECK: ldr [[CALLEE:r[0-3]]], {{\[}}[[TMP]]{{\]}}
15
16; CHECK-V4T-NOT: blx
17; CHECK-V4T: bl [[INDIRECT_PAD:\.Ltmp[0-9]+]]
18; CHECK-V4T: [[F]]:
19; CHECK-V4T: [[INDIRECT_PAD]]:
20; CHECK-V4T-NEXT: bx [[CALLEE]]
21; CHECK-V5T: blx [[CALLEE]]
22}
23
24; CHECK-LABEL: bar:
25define void @bar(void (i32)* nocapture %g, i32 %x, void (i32)* nocapture %h) {
26entry:
27  tail call void %g(i32 %x)
28  tail call void %h(i32 %x)
29  ret void
30
31; CHECK-V4T: bl [[INDIRECT_PAD1:\.Ltmp[0-9]+]]
32; CHECK-V4T: bl [[INDIRECT_PAD2:\.Ltmp[0-9]+]]
33; CHECK-V4T: [[INDIRECT_PAD1]]:
34; CHECK-V4T-NEXT: bx
35; CHECK-V4T: [[INDIRECT_PAD2]]:
36; CHECK-V4T-NEXT: bx
37; CHECK-V5T: blx
38; CHECK-V5T: blx
39}
40