2014-05-24 12:50:23 +00:00
|
|
|
; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s --check-prefix=CHECK
|
|
|
|
; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=-fp-armv8 -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-NOFP-ARM64 %s
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
declare void @use_addr(i8*)
|
|
|
|
|
|
|
|
define void @test_simple_alloca(i64 %n) {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_simple_alloca:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%buf = alloca i8, i64 %n
|
|
|
|
; Make sure we align the stack change to 16 bytes:
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: {{mov|add}} x29
|
|
|
|
; CHECK: mov [[TMP:x[0-9]+]], sp
|
|
|
|
; CHECK: add [[SPDELTA_TMP:x[0-9]+]], x0, #15
|
|
|
|
; CHECK: and [[SPDELTA:x[0-9]+]], [[SPDELTA_TMP]], #0xfffffffffffffff0
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; Make sure we change SP. It would be surprising if anything but x0 were used
|
|
|
|
; for the final sp, but it could be if it was then moved into x0.
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: sub [[NEWSP:x[0-9]+]], [[TMP]], [[SPDELTA]]
|
|
|
|
; CHECK: mov sp, [[NEWSP]]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
call void @use_addr(i8* %buf)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
|
|
|
ret void
|
|
|
|
; Make sure epilogue restores sp from fp
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: {{sub|mov}} sp, x29
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @use_addr_loc(i8*, i64*)
|
|
|
|
|
|
|
|
define i64 @test_alloca_with_local(i64 %n) {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_alloca_with_local:
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK-DAG: sub sp, sp, [[LOCAL_STACK:#[0-9]+]]
|
|
|
|
; CHECK-DAG: {{mov|add}} x29, sp
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%loc = alloca i64
|
|
|
|
%buf = alloca i8, i64 %n
|
|
|
|
; Make sure we align the stack change to 16 bytes:
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: mov [[TMP:x[0-9]+]], sp
|
|
|
|
; CHECK: add [[SPDELTA_TMP:x[0-9]+]], x0, #15
|
|
|
|
; CHECK: and [[SPDELTA:x[0-9]+]], [[SPDELTA_TMP]], #0xfffffffffffffff0
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; Make sure we change SP. It would be surprising if anything but x0 were used
|
|
|
|
; for the final sp, but it could be if it was then moved into x0.
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: sub [[NEWSP:x[0-9]+]], [[TMP]], [[SPDELTA]]
|
|
|
|
; CHECK: mov sp, [[NEWSP]]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: sub {{x[0-9]+}}, x29, #[[LOC_FROM_FP:[0-9]+]]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
call void @use_addr_loc(i8* %buf, i64* %loc)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
2015-02-27 21:17:42 +00:00
|
|
|
%val = load i64, i64* %loc
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: ldur x0, [x29, #-[[LOC_FROM_FP]]]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
ret i64 %val
|
|
|
|
; Make sure epilogue restores sp from fp
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK: {{sub|mov}} sp, x29
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_variadic_alloca(i64 %n, ...) {
|
2014-04-14 12:50:58 +00:00
|
|
|
; CHECK-LABEL: test_variadic_alloca:
|
|
|
|
|
2013-01-31 12:12:40 +00:00
|
|
|
; [...]
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2013-10-31 09:32:11 +00:00
|
|
|
|
2014-04-25 09:44:20 +00:00
|
|
|
; CHECK-NOFP-AARCH64: sub sp, sp, #80
|
|
|
|
; CHECK-NOFP-AARCH64: stp x29, x30, [sp, #64]
|
|
|
|
; CHECK-NOFP-AARCH64: add x29, sp, #64
|
|
|
|
; CHECK-NOFP-AARCH64: sub [[TMP:x[0-9]+]], x29, #64
|
|
|
|
; CHECK-NOFP-AARCH64: add x8, [[TMP]], #0
|
2013-01-31 12:12:40 +00:00
|
|
|
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: stp x29, x30, [sp, #-16]!
|
|
|
|
; CHECK: mov x29, sp
|
|
|
|
; CHECK: sub sp, sp, #192
|
|
|
|
; CHECK: stp q6, q7, [x29, #-96]
|
2014-04-14 12:50:58 +00:00
|
|
|
; [...]
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: stp q0, q1, [x29, #-192]
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: stp x6, x7, [x29, #-16]
|
2014-04-14 12:50:58 +00:00
|
|
|
; [...]
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: stp x2, x3, [x29, #-48]
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-04-25 09:44:20 +00:00
|
|
|
; CHECK-NOFP-ARM64: stp x29, x30, [sp, #-16]!
|
|
|
|
; CHECK-NOFP-ARM64: mov x29, sp
|
|
|
|
; CHECK-NOFP-ARM64: sub sp, sp, #64
|
|
|
|
; CHECK-NOFP-ARM64: stp x6, x7, [x29, #-16]
|
|
|
|
; [...]
|
|
|
|
; CHECK-NOFP-ARM64: stp x4, x5, [x29, #-32]
|
|
|
|
; [...]
|
|
|
|
; CHECK-NOFP-ARM64: stp x2, x3, [x29, #-48]
|
|
|
|
; [...]
|
|
|
|
; CHECK-NOFP-ARM64: mov x8, sp
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2013-01-31 12:12:40 +00:00
|
|
|
%addr = alloca i8, i64 %n
|
|
|
|
|
|
|
|
call void @use_addr(i8* %addr)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
|
|
|
ret void
|
2013-10-31 09:32:11 +00:00
|
|
|
|
2014-04-25 09:44:20 +00:00
|
|
|
; CHECK-NOFP-AARCH64: sub sp, x29, #64
|
|
|
|
; CHECK-NOFP-AARCH64: ldp x29, x30, [sp, #64]
|
|
|
|
; CHECK-NOFP-AARCH64: add sp, sp, #80
|
|
|
|
|
|
|
|
; CHECK-NOFP-ARM64: mov sp, x29
|
|
|
|
; CHECK-NOFP-ARM64: ldp x29, x30, [sp], #16
|
2013-01-31 12:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_alloca_large_frame(i64 %n) {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_alloca_large_frame:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: stp x20, x19, [sp, #-32]!
|
|
|
|
; CHECK: stp x29, x30, [sp, #16]
|
|
|
|
; CHECK: add x29, sp, #16
|
|
|
|
; CHECK: sub sp, sp, #1953, lsl #12
|
|
|
|
; CHECK: sub sp, sp, #512
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%addr1 = alloca i8, i64 %n
|
|
|
|
%addr2 = alloca i64, i64 1000000
|
|
|
|
|
|
|
|
call void @use_addr_loc(i8* %addr1, i64* %addr2)
|
|
|
|
|
|
|
|
ret void
|
2014-04-14 12:50:58 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
; CHECK: sub sp, x29, #16
|
|
|
|
; CHECK: ldp x29, x30, [sp, #16]
|
|
|
|
; CHECK: ldp x20, x19, [sp], #32
|
2013-01-31 12:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare i8* @llvm.stacksave()
|
|
|
|
declare void @llvm.stackrestore(i8*)
|
|
|
|
|
|
|
|
define void @test_scoped_alloca(i64 %n) {
|
2013-10-09 07:53:57 +00:00
|
|
|
; CHECK-LABEL: test_scoped_alloca:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%sp = call i8* @llvm.stacksave()
|
|
|
|
; CHECK: mov [[SAVED_SP:x[0-9]+]], sp
|
2013-10-09 07:53:57 +00:00
|
|
|
; CHECK: mov [[OLDSP:x[0-9]+]], sp
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%addr = alloca i8, i64 %n
|
|
|
|
; CHECK: and [[SPDELTA:x[0-9]+]], {{x[0-9]+}}, #0xfffffffffffffff0
|
2013-10-09 07:53:57 +00:00
|
|
|
; CHECK-DAG: sub [[NEWSP:x[0-9]+]], [[OLDSP]], [[SPDELTA]]
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: mov sp, [[NEWSP]]
|
|
|
|
|
|
|
|
call void @use_addr(i8* %addr)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
|
|
|
call void @llvm.stackrestore(i8* %sp)
|
|
|
|
; CHECK: mov sp, [[SAVED_SP]]
|
|
|
|
|
|
|
|
ret void
|
2013-03-26 18:56:54 +00:00
|
|
|
}
|