1 ; RUN: llc -O0 -stop-before=irtranslator -global-isel %s -o - | FileCheck %s
2 ; RUN: llc -O0 -stop-after=irtranslator -verify-machineinstrs -global-isel %s -o - | FileCheck --check-prefixes CHECK,CHECK-MIR %s
4 ; Check that when using GlobalISel, the StackProtector pass currently inserts
5 ; both prologue and epilogue instrumentation because GlobalISel does not have
6 ; the same epilogue insertion/optimization as SelectionDAG.
8 target triple = "aarch64-none-unknown-eabi"
10 define void @foo() ssp {
12 ; CHECK-NEXT: %StackGuardSlot = alloca i8*
13 ; CHECK-NEXT: %0 = call i8* @llvm.stackguard()
14 ; CHECK-NEXT: call void @llvm.stackprotector(i8* %0, i8** %StackGuardSlot)
15 ; CHECK-NEXT: %buf = alloca [8 x i8], align 1
16 ; CHECK-NEXT: %1 = call i8* @llvm.stackguard()
17 ; CHECK-NEXT: %2 = load volatile i8*, i8** %StackGuardSlot
18 ; CHECK-NEXT: %3 = icmp eq i8* %1, %2
19 ; CHECK-NEXT: br i1 %3, label %SP_return, label %CallStackCheckFailBlk, !prof !0
22 ; CHECK-NEXT: ret void
24 ; CHECK: CallStackCheckFailBlk:
25 ; CHECK-NEXT: call void @__stack_chk_fail()
26 ; CHECK-NEXT: unreachable
28 ; CHECK-MIR: bb.1.entry:
29 ; CHECK-MIR: %0:_(p0) = G_FRAME_INDEX %stack.0.StackGuardSlot
30 ; CHECK-MIR-NEXT: %1:gpr64sp(p0) = LOAD_STACK_GUARD :: (dereferenceable invariant load 8 from @__stack_chk_guard)
31 ; CHECK-MIR-NEXT: %2:gpr64sp(p0) = LOAD_STACK_GUARD :: (dereferenceable invariant load 8 from @__stack_chk_guard)
32 ; CHECK-MIR-NEXT: G_STORE %2(p0), %0(p0) :: (volatile store 8 into %stack.0.StackGuardSlot)
33 ; CHECK-MIR-NEXT: %3:_(p0) = G_FRAME_INDEX %stack.1.buf
34 ; CHECK-MIR-NEXT: %4:gpr64sp(p0) = LOAD_STACK_GUARD :: (dereferenceable invariant load 8 from @__stack_chk_guard)
35 ; CHECK-MIR-NEXT: %5:_(p0) = G_LOAD %0(p0) :: (volatile load 8 from %ir.StackGuardSlot)
36 ; CHECK-MIR-NEXT: %6:_(s1) = G_ICMP intpred(eq), %4(p0), %5
37 ; CHECK-MIR-NEXT: G_BRCOND %6(s1), %bb.2
38 ; CHECK-MIR-NEXT: G_BR %bb.3
40 ; CHECK-MIR: bb.2.SP_return:
41 ; CHECK-MIR-NEXT: RET_ReallyLR
43 ; CHECK-MIR: bb.3.CallStackCheckFailBlk:
44 ; CHECK-MIR-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
45 ; CHECK-MIR-NEXT: BL @__stack_chk_fail, csr_aarch64_aapcs, implicit-def $lr, implicit $sp
46 ; CHECK-MIR-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
48 %buf = alloca [8 x i8], align 1