Skip to content

Commit 6ae7b73

Browse files
committed
[ARM][test] Improve stack-protector tests
llvm/test/LTO/ARM/ssp-static-reloc.ll is more about using the static relocation model with "PIC Level" and unrelated to the LTO infrastructure. Move the test. Update stack_guard_remat.ll to clearly test "PIC Level" with the relevant relocation models.
1 parent e8c0ae6 commit 6ae7b73

File tree

3 files changed

+51
-46
lines changed

3 files changed

+51
-46
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
; RUN: llc -relocation-model=static < %s | FileCheck %s
3+
4+
target triple = "armv7a-linux-gnueabi"
5+
6+
define i32 @test1() #0 {
7+
; CHECK-LABEL: test1:
8+
; CHECK: @ %bb.0:
9+
; CHECK-NEXT: push {r11, lr}
10+
; CHECK-NEXT: sub sp, sp, #8
11+
; CHECK-NEXT: sub sp, sp, #1024
12+
; CHECK-NEXT: movw r0, :lower16:__stack_chk_guard
13+
; CHECK-NEXT: movt r0, :upper16:__stack_chk_guard
14+
; CHECK-NEXT: ldr r0, [r0]
15+
; CHECK-NEXT: ldr r0, [r0]
16+
; CHECK-NEXT: str r0, [sp, #1028]
17+
; CHECK-NEXT: add r0, sp, #4
18+
; CHECK-NEXT: bl foo
19+
; CHECK-NEXT: movw r1, :lower16:__stack_chk_guard
20+
; CHECK-NEXT: ldr r0, [sp, #1028]
21+
; CHECK-NEXT: movt r1, :upper16:__stack_chk_guard
22+
; CHECK-NEXT: ldr r1, [r1]
23+
; CHECK-NEXT: ldr r1, [r1]
24+
; CHECK-NEXT: cmp r1, r0
25+
; CHECK-NEXT: moveq r0, #0
26+
; CHECK-NEXT: addeq sp, sp, #8
27+
; CHECK-NEXT: addeq sp, sp, #1024
28+
; CHECK-NEXT: popeq {r11, pc}
29+
; CHECK-NEXT: .LBB0_1:
30+
; CHECK-NEXT: bl __stack_chk_fail
31+
%a1 = alloca [256 x i32], align 4
32+
call void @foo(ptr %a1) #3
33+
ret i32 0
34+
}
35+
36+
declare void @foo(ptr)
37+
38+
attributes #0 = { nounwind sspstrong }
39+
40+
!llvm.module.flags = !{!0}
41+
!0 = !{i32 8, !"PIC Level", i32 2}

llvm/test/CodeGen/ARM/stack_guard_remat.ll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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
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
79

810
;PIC: foo2
911
;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
@@ -47,6 +49,7 @@
4749
;DYNAMIC-NO-PIC-V7: L___stack_chk_guard$non_lazy_ptr:
4850
;DYNAMIC-NO-PIC-V7: .indirect_symbol ___stack_chk_guard
4951

52+
;--- main.ll
5053
; Function Attrs: nounwind ssp
5154
define i32 @test_stack_guard_remat() #0 {
5255
%a1 = alloca [256 x i32], align 4
@@ -67,5 +70,6 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
6770

6871
attributes #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" }
6972

73+
;--- pic-flag.ll
7074
!llvm.module.flags = !{!0}
7175
!0 = !{i32 7, !"PIC Level", i32 2}

llvm/test/LTO/ARM/ssp-static-reloc.ll

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)