1*9880d681SAndroid Build Coastguard Worker# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o - %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker# This test ensures that the MIR parser parses the stack protector stack 3*9880d681SAndroid Build Coastguard Worker# object reference in the machine frame info correctly. 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker--- | 6*9880d681SAndroid Build Coastguard Worker @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 7*9880d681SAndroid Build Coastguard Worker @__stack_chk_guard = external global i8* 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Worker define i32 @test() #0 { 10*9880d681SAndroid Build Coastguard Worker entry: 11*9880d681SAndroid Build Coastguard Worker %StackGuardSlot = alloca i8* 12*9880d681SAndroid Build Coastguard Worker %StackGuard = load i8*, i8** @__stack_chk_guard 13*9880d681SAndroid Build Coastguard Worker call void @llvm.stackprotector(i8* %StackGuard, i8** %StackGuardSlot) 14*9880d681SAndroid Build Coastguard Worker %test = alloca i8*, align 8 15*9880d681SAndroid Build Coastguard Worker %a = alloca i8, i64 5 16*9880d681SAndroid Build Coastguard Worker store i8* %a, i8** %test, align 8 17*9880d681SAndroid Build Coastguard Worker %b = load i8*, i8** %test, align 8 18*9880d681SAndroid Build Coastguard Worker %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* %b) 19*9880d681SAndroid Build Coastguard Worker call void @llvm.stackprotectorcheck(i8** @__stack_chk_guard) 20*9880d681SAndroid Build Coastguard Worker ret i32 %call 21*9880d681SAndroid Build Coastguard Worker } 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker declare i32 @printf(i8*, ...) 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker declare void @llvm.stackprotector(i8*, i8**) #1 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker declare void @llvm.stackprotectorcheck(i8**) #2 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker attributes #0 = { ssp "stack-protector-buffer-size"="5" } 30*9880d681SAndroid Build Coastguard Worker attributes #1 = { nounwind } 31*9880d681SAndroid Build Coastguard Worker attributes #2 = { nounwind argmemonly } 32*9880d681SAndroid Build Coastguard Worker... 33*9880d681SAndroid Build Coastguard Worker--- 34*9880d681SAndroid Build Coastguard Workername: test 35*9880d681SAndroid Build Coastguard Workeralignment: 4 36*9880d681SAndroid Build Coastguard WorkertracksRegLiveness: true 37*9880d681SAndroid Build Coastguard WorkerframeInfo: 38*9880d681SAndroid Build Coastguard Worker stackSize: 40 39*9880d681SAndroid Build Coastguard Worker maxAlignment: 8 40*9880d681SAndroid Build Coastguard Worker adjustsStack: true 41*9880d681SAndroid Build Coastguard Worker hasCalls: true 42*9880d681SAndroid Build Coastguard Worker# CHECK-LABEL: name: test 43*9880d681SAndroid Build Coastguard Worker# CHECK: frameInfo 44*9880d681SAndroid Build Coastguard Worker# CHECK: stackProtector: '%stack.0.StackGuardSlot' 45*9880d681SAndroid Build Coastguard Worker stackProtector: '%stack.0.StackGuardSlot' 46*9880d681SAndroid Build Coastguard WorkerfixedStack: 47*9880d681SAndroid Build Coastguard Worker - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, 48*9880d681SAndroid Build Coastguard Worker callee-saved-register: '%rbx' } 49*9880d681SAndroid Build Coastguard Workerstack: 50*9880d681SAndroid Build Coastguard Worker - { id: 0, name: StackGuardSlot, offset: -24, size: 8, alignment: 8 } 51*9880d681SAndroid Build Coastguard Worker - { id: 1, name: test, offset: -40, size: 8, alignment: 8 } 52*9880d681SAndroid Build Coastguard Worker - { id: 2, name: a, offset: -29, size: 5, alignment: 1 } 53*9880d681SAndroid Build Coastguard Workerbody: | 54*9880d681SAndroid Build Coastguard Worker bb.0.entry: 55*9880d681SAndroid Build Coastguard Worker successors: %bb.1.entry, %bb.2.entry 56*9880d681SAndroid Build Coastguard Worker liveins: %rbx, %rbx 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp 59*9880d681SAndroid Build Coastguard Worker %rsp = frame-setup SUB64ri8 %rsp, 32, implicit-def dead %eflags 60*9880d681SAndroid Build Coastguard Worker %rbx = LOAD_STACK_GUARD :: (invariant load 8 from @__stack_chk_guard) 61*9880d681SAndroid Build Coastguard Worker MOV64mr %rsp, 1, _, 24, _, %rbx 62*9880d681SAndroid Build Coastguard Worker %rsi = LEA64r %rsp, 1, _, 19, _ 63*9880d681SAndroid Build Coastguard Worker MOV64mr %rsp, 1, _, 8, _, %rsi 64*9880d681SAndroid Build Coastguard Worker %rdi = LEA64r %rip, 1, _, @.str, _ 65*9880d681SAndroid Build Coastguard Worker dead %eax = MOV32r0 implicit-def dead %eflags, implicit-def %al 66*9880d681SAndroid Build Coastguard Worker CALL64pcrel32 @printf, csr_64, implicit %rsp, implicit %rdi, implicit %rsi, implicit %al, implicit-def %rsp, implicit-def %eax 67*9880d681SAndroid Build Coastguard Worker CMP64rm killed %rbx, %rsp, 1, _, 24, _, implicit-def %eflags 68*9880d681SAndroid Build Coastguard Worker JNE_1 %bb.2.entry, implicit %eflags 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker bb.1.entry: 71*9880d681SAndroid Build Coastguard Worker liveins: %eax 72*9880d681SAndroid Build Coastguard Worker 73*9880d681SAndroid Build Coastguard Worker %rsp = ADD64ri8 %rsp, 32, implicit-def dead %eflags 74*9880d681SAndroid Build Coastguard Worker %rbx = POP64r implicit-def %rsp, implicit %rsp 75*9880d681SAndroid Build Coastguard Worker RETQ %eax 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker bb.2.entry: 78*9880d681SAndroid Build Coastguard Worker CALL64pcrel32 $__stack_chk_fail, csr_64, implicit %rsp, implicit-def %rsp 79*9880d681SAndroid Build Coastguard Worker... 80