1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
3 ;; Test target-specific stack cookie location.
5 ; RUN: llc -mtriple=riscv64-linux < %s | FileCheck --check-prefix=LINUX-RISCV64 %s
6 ; RUN: llc -mtriple=riscv64-fuchsia < %s | FileCheck --check-prefix=FUCHSIA-RISCV64 %s
7 ; RUN: llc -mtriple=riscv64-android < %s | FileCheck --check-prefix=ANDROID-RISCV64 %s
9 define void @func() sspreq nounwind {
10 ; LINUX-RISCV64-LABEL: func:
11 ; LINUX-RISCV64: # %bb.0:
12 ; LINUX-RISCV64-NEXT: addi sp, sp, -32
13 ; LINUX-RISCV64-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
14 ; LINUX-RISCV64-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
15 ; LINUX-RISCV64-NEXT: lui s0, %hi(__stack_chk_guard)
16 ; LINUX-RISCV64-NEXT: ld a0, %lo(__stack_chk_guard)(s0)
17 ; LINUX-RISCV64-NEXT: sd a0, 8(sp)
18 ; LINUX-RISCV64-NEXT: addi a0, sp, 4
19 ; LINUX-RISCV64-NEXT: call capture
20 ; LINUX-RISCV64-NEXT: ld a0, %lo(__stack_chk_guard)(s0)
21 ; LINUX-RISCV64-NEXT: ld a1, 8(sp)
22 ; LINUX-RISCV64-NEXT: bne a0, a1, .LBB0_2
23 ; LINUX-RISCV64-NEXT: # %bb.1:
24 ; LINUX-RISCV64-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
25 ; LINUX-RISCV64-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
26 ; LINUX-RISCV64-NEXT: addi sp, sp, 32
27 ; LINUX-RISCV64-NEXT: ret
28 ; LINUX-RISCV64-NEXT: .LBB0_2:
29 ; LINUX-RISCV64-NEXT: call __stack_chk_fail
31 ; FUCHSIA-RISCV64-LABEL: func:
32 ; FUCHSIA-RISCV64: # %bb.0:
33 ; FUCHSIA-RISCV64-NEXT: addi sp, sp, -32
34 ; FUCHSIA-RISCV64-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
35 ; FUCHSIA-RISCV64-NEXT: ld a0, -16(tp)
36 ; FUCHSIA-RISCV64-NEXT: sd a0, 16(sp)
37 ; FUCHSIA-RISCV64-NEXT: addi a0, sp, 12
38 ; FUCHSIA-RISCV64-NEXT: call capture
39 ; FUCHSIA-RISCV64-NEXT: ld a0, -16(tp)
40 ; FUCHSIA-RISCV64-NEXT: ld a1, 16(sp)
41 ; FUCHSIA-RISCV64-NEXT: bne a0, a1, .LBB0_2
42 ; FUCHSIA-RISCV64-NEXT: # %bb.1: # %SP_return
43 ; FUCHSIA-RISCV64-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
44 ; FUCHSIA-RISCV64-NEXT: addi sp, sp, 32
45 ; FUCHSIA-RISCV64-NEXT: ret
46 ; FUCHSIA-RISCV64-NEXT: .LBB0_2: # %CallStackCheckFailBlk
47 ; FUCHSIA-RISCV64-NEXT: call __stack_chk_fail
49 ; ANDROID-RISCV64-LABEL: func:
50 ; ANDROID-RISCV64: # %bb.0:
51 ; ANDROID-RISCV64-NEXT: addi sp, sp, -32
52 ; ANDROID-RISCV64-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
53 ; ANDROID-RISCV64-NEXT: ld a0, -24(tp)
54 ; ANDROID-RISCV64-NEXT: sd a0, 16(sp)
55 ; ANDROID-RISCV64-NEXT: addi a0, sp, 12
56 ; ANDROID-RISCV64-NEXT: call capture
57 ; ANDROID-RISCV64-NEXT: ld a0, -24(tp)
58 ; ANDROID-RISCV64-NEXT: ld a1, 16(sp)
59 ; ANDROID-RISCV64-NEXT: bne a0, a1, .LBB0_2
60 ; ANDROID-RISCV64-NEXT: # %bb.1: # %SP_return
61 ; ANDROID-RISCV64-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
62 ; ANDROID-RISCV64-NEXT: addi sp, sp, 32
63 ; ANDROID-RISCV64-NEXT: ret
64 ; ANDROID-RISCV64-NEXT: .LBB0_2: # %CallStackCheckFailBlk
65 ; ANDROID-RISCV64-NEXT: call __stack_chk_fail
66 %1 = alloca i32, align 4
67 call void @capture(ptr %1)
71 declare void @capture(ptr)