1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -global-isel=1 -mtriple=aarch64-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: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill
12 ; CHECK-NEXT: str x19, [sp, #16] // 8-byte Folded Spill
13 ; CHECK-NEXT: mov x29, sp
14 ; CHECK-NEXT: .cfi_def_cfa w29, 32
15 ; CHECK-NEXT: .cfi_offset w19, -16
16 ; CHECK-NEXT: .cfi_offset w30, -24
17 ; CHECK-NEXT: .cfi_offset w29, -32
18 ; CHECK-NEXT: add x9, x0, #15
19 ; CHECK-NEXT: mov x8, sp
20 ; CHECK-NEXT: mov x19, sp
21 ; CHECK-NEXT: and x9, x9, #0xfffffffffffffff0
22 ; CHECK-NEXT: sub x0, x8, x9
23 ; CHECK-NEXT: mov sp, x0
24 ; CHECK-NEXT: bl use_addr
25 ; CHECK-NEXT: mov sp, x19
26 ; CHECK-NEXT: mov sp, x29
27 ; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Folded Reload
28 ; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload
30 %sp = call ptr @llvm.stacksave.p0()
31 %addr = alloca i8, i64 %n
32 call void @use_addr(ptr %addr)
33 call void @llvm.stackrestore.p0(ptr %sp)