1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -global-isel=1 -mtriple=x86_64-linux-gnu -o - %s | FileCheck %s
4 declare void @use_addr(ptr)
5 declare ptr @llvm.stacksave.p0()
6 declare void @llvm.stackrestore.p0(ptr)
8 define void @test_scoped_alloca(i64 %n) {
9 ; CHECK-LABEL: test_scoped_alloca:
11 ; CHECK-NEXT: pushq %rbp
12 ; CHECK-NEXT: .cfi_def_cfa_offset 16
13 ; CHECK-NEXT: .cfi_offset %rbp, -16
14 ; CHECK-NEXT: movq %rsp, %rbp
15 ; CHECK-NEXT: .cfi_def_cfa_register %rbp
16 ; CHECK-NEXT: pushq %rbx
17 ; CHECK-NEXT: pushq %rax
18 ; CHECK-NEXT: .cfi_offset %rbx, -24
19 ; CHECK-NEXT: movq %rsp, %rbx
20 ; CHECK-NEXT: movq %rsp, %rax
21 ; CHECK-NEXT: imulq $1, %rdi, %rcx
22 ; CHECK-NEXT: addq $15, %rcx
23 ; CHECK-NEXT: andq $-16, %rcx
24 ; CHECK-NEXT: subq %rcx, %rax
25 ; CHECK-NEXT: movq %rax, %rsp
26 ; CHECK-NEXT: movq %rax, %rdi
27 ; CHECK-NEXT: callq use_addr
28 ; CHECK-NEXT: movq %rbx, %rsp
29 ; CHECK-NEXT: leaq -8(%rbp), %rsp
30 ; CHECK-NEXT: popq %rbx
31 ; CHECK-NEXT: popq %rbp
32 ; CHECK-NEXT: .cfi_def_cfa %rsp, 8
34 %sp = call ptr @llvm.stacksave.p0()
35 %addr = alloca i8, i64 %n
36 call void @use_addr(ptr %addr)
37 call void @llvm.stackrestore.p0(ptr %sp)