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. 4 5 --- | 6 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 7 @__stack_chk_guard = external global i8* 8 9 define i32 @test() #0 { 10 entry: 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 15 %a = alloca i8, i64 5 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) 20 ret i32 %call 21 } 22 23 declare i32 @printf(i8*, ...) 24 25 declare void @llvm.stackprotector(i8*, i8**) #1 26 27 declare void @llvm.stackprotectorcheck(i8**) #2 28 29 attributes #0 = { ssp "stack-protector-buffer-size"="5" } 30 attributes #1 = { nounwind } 31 attributes #2 = { nounwind argmemonly } 32 ... 33 --- 34 name: test 35 alignment: 4 36 tracksRegLiveness: true 37 frameInfo: 38 stackSize: 40 39 maxAlignment: 8 40 adjustsStack: true 41 hasCalls: true 42 # CHECK-LABEL: name: test 43 # CHECK: frameInfo 44 # CHECK: stackProtector: '%stack.0.StackGuardSlot' 45 stackProtector: '%stack.0.StackGuardSlot' 46 fixedStack: 47 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, 48 callee-saved-register: '%rbx' } 49 stack: 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 } 53 body: | 54 bb.0.entry: 55 successors: %bb.1.entry, %bb.2.entry 56 liveins: %rbx, %rbx 57 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 69 70 bb.1.entry: 71 liveins: %eax 72 73 %rsp = ADD64ri8 %rsp, 32, implicit-def dead %eflags 74 %rbx = POP64r implicit-def %rsp, implicit %rsp 75 RETQ %eax 76 77 bb.2.entry: 78 CALL64pcrel32 $__stack_chk_fail, csr_64, implicit %rsp, implicit-def %rsp 79 ... 80