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