Debian Codegraph @

llvm/test/CodeGen/PowerPC/GlobalISel/ppc-irtranslator-stackprotect.ll

raw
1 ; RUN: llc -verify-machineinstrs -mtriple=ppc64le-unknown-linux %s -global-isel -stop-after=irtranslator -o - | FileCheck %s --check-prefix=LINUX
2 ; RUN: llc -verify-machineinstrs -mtriple=ppc64le-unknown-openbsd %s -global-isel -stop-after=irtranslator -o - | FileCheck %s --check-prefix=OPENBSD
3
4
5 ; The stack guard on Linux
6 @__stack_chk_guard = external global ptr
7
8 ; The stack guard on OpenBSD
9 @__guard_local = external hidden global ptr
10
11 declare void @llvm.stackprotector(ptr, ptr)
12
13 ; LINUX-LABEL: name: test_stack_guard_linux
14
15 ; LINUX: frameInfo:
16 ; LINUX: stackProtector: '%stack.0.StackGuardSlot'
17
18 ; LINUX: stack:
19 ; LINUX: - { id: 0, name: StackGuardSlot, type: default, offset: 0, size: 8, alignment: 8,
20 ; LINUX-NOT: id: 1
21
22 ; LINUX: [[GUARD_SLOT:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.StackGuardSlot
23 ; LINUX: [[GUARD:%[0-9]+]]:g8rc(p0) = LOAD_STACK_GUARD :: (dereferenceable invariant load (p0) from @__stack_chk_guard)
24 ; LINUX: G_STORE [[GUARD]](p0), [[GUARD_SLOT]](p0) :: (volatile store (p0) into %stack.0.StackGuardSlot)
25 define void @test_stack_guard_linux() {
26 %StackGuardSlot = alloca ptr
27 call void @llvm.stackprotector(ptr undef, ptr %StackGuardSlot)
28 ret void
29 }
30
31 ; OPENBSD-LABEL: name: test_stack_guard_openbsd
32
33 ; OPENBSD: frameInfo:
34 ; OPENBSD: stackProtector: '%stack.0.StackGuardSlot'
35
36 ; OPENBSD: stack:
37 ; OPENBSD: - { id: 0, name: StackGuardSlot, type: default, offset: 0, size: 8, alignment: 8,
38 ; OPENBSD-NOT: id: 1
39
40 ; OPENBSD: [[GUARD_LOCAL:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @__guard_local
41 ; OPENBSD: [[GUARD_SLOT:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.StackGuardSlot
42 ; OPENBSD: [[GUARD:%[0-9]+]]:_(p0) = G_LOAD [[GUARD_LOCAL]](p0) :: (dereferenceable load (p0) from @__guard_local)
43 ; OPENBSD: G_STORE [[GUARD]](p0), [[GUARD_SLOT]](p0) :: (volatile store (p0) into %stack.0.StackGuardSlot)
44 define void @test_stack_guard_openbsd() {
45 %StackGuardSlot = alloca ptr
46 %StackGuard = load ptr, ptr @__guard_local
47 call void @llvm.stackprotector(ptr %StackGuard, ptr %StackGuardSlot)
48 ret void
49 }