xref: /llvm-project/llvm/test/CodeGen/AArch64/stack-guard-remat-bitcast.ll (revision 6e54fccede402c9ed0e8038aa258a99c5a2773e5)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=arm64-apple-ios -relocation-model=pic -frame-pointer=all | FileCheck %s
3
4@__stack_chk_guard = external global ptr
5
6; PR20558
7
8; Load the stack guard for the second time, just in case the previous value gets spilled.
9define i32 @test_stack_guard_remat2() ssp {
10; CHECK-LABEL: test_stack_guard_remat2:
11; CHECK:       ; %bb.0: ; %entry
12; CHECK-NEXT:    sub sp, sp, #64
13; CHECK-NEXT:    stp x29, x30, [sp, #48] ; 16-byte Folded Spill
14; CHECK-NEXT:    add x29, sp, #48
15; CHECK-NEXT:    .cfi_def_cfa w29, 16
16; CHECK-NEXT:    .cfi_offset w30, -8
17; CHECK-NEXT:    .cfi_offset w29, -16
18; CHECK-NEXT:  Lloh0:
19; CHECK-NEXT:    adrp x8, ___stack_chk_guard@GOTPAGE
20; CHECK-NEXT:  Lloh1:
21; CHECK-NEXT:    adrp x9, ___stack_chk_guard@GOTPAGE
22; CHECK-NEXT:  Lloh2:
23; CHECK-NEXT:    ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
24; CHECK-NEXT:  Lloh3:
25; CHECK-NEXT:    ldr x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
26; CHECK-NEXT:  Lloh4:
27; CHECK-NEXT:    ldr x8, [x8]
28; CHECK-NEXT:  Lloh5:
29; CHECK-NEXT:    ldr x9, [x9]
30; CHECK-NEXT:    str x8, [sp]
31; CHECK-NEXT:    stur x9, [x29, #-8]
32; CHECK-NEXT:    ldur x9, [x29, #-8]
33; CHECK-NEXT:    cmp x8, x9
34; CHECK-NEXT:    b.ne LBB0_2
35; CHECK-NEXT:  ; %bb.1: ; %entry
36; CHECK-NEXT:    ldp x29, x30, [sp, #48] ; 16-byte Folded Reload
37; CHECK-NEXT:    mov w0, #-1
38; CHECK-NEXT:    add sp, sp, #64
39; CHECK-NEXT:    ret
40; CHECK-NEXT:  LBB0_2: ; %entry
41; CHECK-NEXT:    bl ___stack_chk_fail
42; CHECK-NEXT:    .loh AdrpLdrGotLdr Lloh1, Lloh3, Lloh5
43; CHECK-NEXT:    .loh AdrpLdrGotLdr Lloh0, Lloh2, Lloh4
44entry:
45  %StackGuardSlot = alloca ptr
46  %StackGuard = load ptr, ptr @__stack_chk_guard
47  call void @llvm.stackprotector(ptr %StackGuard, ptr %StackGuardSlot)
48  %container = alloca [32 x i8], align 1
49  call void @llvm.stackprotectorcheck(ptr @__stack_chk_guard)
50  ret i32 -1
51}
52
53declare void @llvm.stackprotector(ptr, ptr) ssp
54declare void @llvm.stackprotectorcheck(ptr) ssp
55