1; RUN: llc  %s -mtriple=thumbv7-linux-gnueabi -o - | \
2; RUN:    FileCheck  -check-prefix=ELFASM %s
3; RUN: llc  %s -mtriple=thumbebv7-linux-gnueabi -o - | \
4; RUN:    FileCheck  -check-prefix=ELFASM %s
5; RUN: llc  %s -mtriple=thumbv7-linux-gnueabi -filetype=obj -o - | \
6; RUN:    llvm-readobj -s -sd | FileCheck  -check-prefix=ELFOBJ -check-prefix=ELFOBJ-LE %s
7; RUN: llc  %s -mtriple=thumbebv7-linux-gnueabi -filetype=obj -o - | \
8; RUN:    llvm-readobj -s -sd | FileCheck  -check-prefix=ELFOBJ -check-prefix=ELFOBJ-BE %s
9
10;; Make sure that bl __aeabi_read_tp is materialized and fixed up correctly
11;; in the obj case.
12
13@i = external thread_local global i32
14@a = external global i8
15@b = external global [10 x i8]
16
17define arm_aapcs_vfpcc i32 @main() nounwind {
18entry:
19  %0 = load i32, i32* @i, align 4
20  switch i32 %0, label %bb2 [
21    i32 12, label %bb
22    i32 13, label %bb1
23  ]
24
25bb:                                               ; preds = %entry
26  %1 = tail call arm_aapcs_vfpcc  i32 @foo(i8* @a) nounwind
27  ret i32 %1
28; ELFASM:       	bl	__aeabi_read_tp
29
30
31; ELFOBJ:      Sections [
32; ELFOBJ:        Section {
33; ELFOBJ:          Name: .text
34; ELFOBJ-LE:          SectionData (
35;;;                  BL __aeabi_read_tp is ---+
36;;;                                           V
37; ELFOBJ-LE-NEXT:     0000: 80B50E48 78440168 FFF7FEFF 40580D28
38; ELFOBJ-BE:          SectionData (
39;;;                  BL __aeabi_read_tp is ---+
40;;;                                           V
41; ELFOBJ-BE-NEXT:     0000: B580480E 44786801 F7FFFFFE 5840280D
42
43
44bb1:                                              ; preds = %entry
45  %2 = tail call arm_aapcs_vfpcc  i32 @bar(i32* bitcast ([10 x i8]* @b to i32*)) nounwind
46  ret i32 %2
47
48bb2:                                              ; preds = %entry
49  ret i32 -1
50}
51
52declare arm_aapcs_vfpcc i32 @foo(i8*)
53
54declare arm_aapcs_vfpcc i32 @bar(i32*)
55