1; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
2; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
3; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s  -check-prefix=NO-PIC -check-prefix=DYNAMIC-NO-PIC
4; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC-V7
5; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC-V7
6; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=DYNAMIC-NO-PIC-V7
7
8;PIC:   foo2
9;PIC:   ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
10;PIC: [[LABEL1:LPC0_1]]:
11;PIC:   add [[R1:r[0-9]+]], pc, [[R0]]
12;PIC:   ldr [[R2:r[0-9]+]], {{\[}}[[R1]]{{\]}}
13;PIC:   ldr {{r[0-9]+}}, {{\[}}[[R2]]{{\]}}
14
15;PIC:      [[LABEL0]]:
16;PIC-NEXT:   .long L___stack_chk_guard$non_lazy_ptr-([[LABEL1]]+8)
17
18;NO-PIC: foo2
19;NO-PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
20;NO-PIC-NOT: LPC
21;NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
22
23;STATIC:      [[LABEL0]]:
24;STATIC-NEXT:   .long ___stack_chk_guard
25
26;DYNAMIC-NO-PIC:      [[LABEL0]]:
27;DYNAMIC-NO-PIC-NEXT:   .long L___stack_chk_guard$non_lazy_ptr
28
29;PIC-V7:   movw [[R0:r[0-9]+]], :lower16:(L___stack_chk_guard$non_lazy_ptr-([[LABEL0:LPC[0-9_]+]]+8))
30;PIC-V7:   movt [[R0]], :upper16:(L___stack_chk_guard$non_lazy_ptr-([[LABEL0]]+8))
31;PIC-V7: [[LABEL0]]:
32;PIC-V7:   ldr [[R0]], {{\[}}pc, [[R0]]{{\]}}
33;PIC-V7:   ldr [[R0]], {{\[}}[[R0]]{{\]}}
34
35;PIC-V7: L___stack_chk_guard$non_lazy_ptr:
36;PIC-V7:   .indirect_symbol        ___stack_chk_guard
37
38;STATIC-V7: movw [[R0:r[0-9]+]], :lower16:___stack_chk_guard
39;STATIC-V7: movt [[R0]], :upper16:___stack_chk_guard
40;STATIC-V7: ldr  [[R0]], {{\[}}[[R0]]{{\]}}
41
42;DYNAMIC-NO-PIC-V7: movw [[R0:r[0-9]+]], :lower16:L___stack_chk_guard$non_lazy_ptr
43;DYNAMIC-NO-PIC-V7: movt [[R0]], :upper16:L___stack_chk_guard$non_lazy_ptr
44;DYNAMIC-NO-PIC-V7: ldr  [[R0]], {{\[}}[[R0]]{{\]}}
45;DYNAMIC-NO-PIC-V7: ldr  [[R0]], {{\[}}[[R0]]{{\]}}
46
47;DYNAMIC-NO-PIC-V7: L___stack_chk_guard$non_lazy_ptr:
48;DYNAMIC-NO-PIC-V7:   .indirect_symbol        ___stack_chk_guard
49
50; Function Attrs: nounwind ssp
51define i32 @test_stack_guard_remat() #0 {
52  %a1 = alloca [256 x i32], align 4
53  %1 = bitcast [256 x i32]* %a1 to i8*
54  call void @llvm.lifetime.start.p0i8(i64 1024, i8* %1)
55  %2 = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 0
56  call void @foo3(i32* %2) #3
57  call void asm sideeffect "foo2", "~{r0},~{r1},~{r2},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{sp},~{lr}"()
58  call void @llvm.lifetime.end.p0i8(i64 1024, i8* %1)
59  ret i32 0
60}
61
62; Function Attrs: nounwind
63declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
64
65declare void @foo3(i32*)
66
67; Function Attrs: nounwind
68declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
69
70attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
71