1 # RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
2 # This test ensures that the MIR parser parses the stack protector stack
3 # object reference in the machine frame info correctly.
6 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
7 @__stack_chk_guard = external global i8*
9 define i32 @test() #0 {
11 %StackGuardSlot = alloca i8*
12 %StackGuard = load i8*, i8** @__stack_chk_guard
13 call void @llvm.stackprotector(i8* %StackGuard, i8** %StackGuardSlot)
14 %test = alloca i8*, align 8
16 store i8* %a, i8** %test, align 8
17 %b = load i8*, i8** %test, align 8
18 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* %b)
19 call void @llvm.stackprotectorcheck(i8** @__stack_chk_guard)
23 declare i32 @printf(i8*, ...)
25 declare void @llvm.stackprotector(i8*, i8**) #1
27 declare void @llvm.stackprotectorcheck(i8**) #2
29 attributes #0 = { ssp "stack-protector-buffer-size"="5" }
30 attributes #1 = { nounwind }
31 attributes #2 = { nounwind argmemonly }
36 tracksRegLiveness: true
42 # CHECK-LABEL: name: test
44 # CHECK: stackProtector: '%stack.0.StackGuardSlot'
45 stackProtector: '%stack.0.StackGuardSlot'
47 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16,
48 callee-saved-register: '%rbx' }
50 - { id: 0, name: StackGuardSlot, offset: -24, size: 8, alignment: 8 }
51 - { id: 1, name: test, offset: -40, size: 8, alignment: 8 }
52 - { id: 2, name: a, offset: -29, size: 5, alignment: 1 }
55 successors: %bb.1.entry, %bb.2.entry
58 frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
59 %rsp = frame-setup SUB64ri8 %rsp, 32, implicit-def dead %eflags
60 %rbx = LOAD_STACK_GUARD :: (invariant load 8 from @__stack_chk_guard)
61 MOV64mr %rsp, 1, _, 24, _, %rbx
62 %rsi = LEA64r %rsp, 1, _, 19, _
63 MOV64mr %rsp, 1, _, 8, _, %rsi
64 %rdi = LEA64r %rip, 1, _, @.str, _
65 dead %eax = MOV32r0 implicit-def dead %eflags, implicit-def %al
66 CALL64pcrel32 @printf, csr_64, implicit %rsp, implicit %rdi, implicit %rsi, implicit %al, implicit-def %rsp, implicit-def %eax
67 CMP64rm killed %rbx, %rsp, 1, _, 24, _, implicit-def %eflags
68 JNE_1 %bb.2.entry, implicit %eflags
73 %rsp = ADD64ri8 %rsp, 32, implicit-def dead %eflags
74 %rbx = POP64r implicit-def %rsp, implicit %rsp
78 CALL64pcrel32 $__stack_chk_fail, csr_64, implicit %rsp, implicit-def %rsp