1; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=pic -o -  %s | FileCheck %s --check-prefix=CHECK-THUMB-PIC
2; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=pic -o -  %s | FileCheck %s --check-prefix=CHECK-ARM-PIC
3; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=dynamic-no-pic -o -  %s | FileCheck %s --check-prefix=CHECK-DYNAMIC
4; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=dynamic-no-pic -o -  %s | FileCheck %s --check-prefix=CHECK-DYNAMIC
5; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=static -o -  %s | FileCheck %s --check-prefix=CHECK-STATIC
6; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=static -o -  %s | FileCheck %s --check-prefix=CHECK-STATIC
7@var = global [16 x i32] zeroinitializer
8
9declare void @bar(i32*)
10
11define void @foo() {
12  %flag = load i32, i32* getelementptr inbounds([16 x i32], [16 x i32]* @var, i32 0, i32 1)
13  %tst = icmp eq i32 %flag, 0
14  br i1 %tst, label %true, label %false
15true:
16  tail call void @bar(i32* getelementptr inbounds([16 x i32], [16 x i32]* @var, i32 0, i32 4))
17  ret void
18false:
19  ret void
20}
21
22; CHECK-THUMB-PIC-LABEL: foo:
23; CHECK-THUMB-PIC: ldr r0, LCPI0_0
24; CHECK-THUMB-PIC: LPC0_0:
25; CHECK-THUMB-PIC-NEXT: add r0, pc
26; CHECK-THUMB-PIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
27
28; CHECK-THUMB-PIC: LCPI0_0:
29; CHECK-THUMB-PIC-NEXT: .long _var-(LPC0_0+4)
30; CHECK-THUMB-PIC-NOT: LCPI0_1
31
32
33; CHECK-ARM-PIC-LABEL: foo:
34; CHECK-ARM-PIC: ldr [[VAR_OFFSET:r[0-9]+]], LCPI0_0
35; CHECK-ARM-PIC: LPC0_0:
36; CHECK-ARM-PIC-NEXT: add r0, pc, [[VAR_OFFSET]]
37; CHECK-ARM-PIC: ldr {{r[0-9]+}}, [r0, #4]
38
39; CHECK-ARM-PIC: LCPI0_0:
40; CHECK-ARM-PIC-NEXT: .long _var-(LPC0_0+8)
41; CHECK-ARM-PIC-NOT: LCPI0_1
42
43
44; CHECK-DYNAMIC-LABEL: foo:
45; CHECK-DYNAMIC: ldr r0, LCPI0_0
46; CHECK-DYNAMIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
47
48; CHECK-DYNAMIC: LCPI0_0:
49; CHECK-DYNAMIC-NEXT: .long _var
50; CHECK-DYNAMIC-NOT: LCPI0_1
51
52
53; CHECK-STATIC-LABEL: foo:
54; CHECK-STATIC: ldr r0, LCPI0_0
55; CHECK-STATIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
56
57; CHECK-STATIC: LCPI0_0:
58; CHECK-STATIC-NEXT: .long _var{{$}}
59; CHECK-STATIC-NOT: LCPI0_1
60
61
62