2016-04-20 07:51:52 +08:00
|
|
|
; RUN: llc -mtriple=aarch64-linux-gnu -disable-post-ra -verify-machineinstrs -o - %s | FileCheck %s
|
2016-02-13 00:31:41 +08:00
|
|
|
; RUN: llc -mtriple=arm64-apple-ios -disable-post-ra -verify-machineinstrs -o - %s | FileCheck %s --check-prefix=CHECK-MACHO
|
2015-12-21 22:43:45 +08:00
|
|
|
; RUN: llc -mtriple=aarch64-none-linux-gnu -disable-post-ra -mattr=-fp-armv8 -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-NOFP-ARM64 %s
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
declare void @use_addr(i8*)
|
|
|
|
|
|
|
|
define void @test_simple_alloca(i64 %n) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test_simple_alloca:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
%buf = alloca i8, i64 %n
|
|
|
|
; Make sure we align the stack change to 16 bytes:
|
2014-04-14 20:50:58 +08: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 20:12:40 +08: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 20:50:58 +08:00
|
|
|
; CHECK: sub [[NEWSP:x[0-9]+]], [[TMP]], [[SPDELTA]]
|
|
|
|
; CHECK: mov sp, [[NEWSP]]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
call void @use_addr(i8* %buf)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
|
|
|
ret void
|
|
|
|
; Make sure epilogue restores sp from fp
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: {{sub|mov}} sp, x29
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @use_addr_loc(i8*, i64*)
|
|
|
|
|
|
|
|
define i64 @test_alloca_with_local(i64 %n) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test_alloca_with_local:
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK-DAG: sub sp, sp, [[LOCAL_STACK:#[0-9]+]]
|
|
|
|
; CHECK-DAG: {{mov|add}} x29, sp
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
%loc = alloca i64
|
|
|
|
%buf = alloca i8, i64 %n
|
|
|
|
; Make sure we align the stack change to 16 bytes:
|
2014-04-14 20:50:58 +08: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 20:12:40 +08: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 20:50:58 +08:00
|
|
|
; CHECK: sub [[NEWSP:x[0-9]+]], [[TMP]], [[SPDELTA]]
|
|
|
|
; CHECK: mov sp, [[NEWSP]]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: sub {{x[0-9]+}}, x29, #[[LOC_FROM_FP:[0-9]+]]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
call void @use_addr_loc(i8* %buf, i64* %loc)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i64, i64* %loc
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
; CHECK: ldur x0, [x29, #-[[LOC_FROM_FP]]]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
ret i64 %val
|
|
|
|
; Make sure epilogue restores sp from fp
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: {{sub|mov}} sp, x29
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_variadic_alloca(i64 %n, ...) {
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK-LABEL: test_variadic_alloca:
|
|
|
|
|
2013-01-31 20:12:40 +08:00
|
|
|
; [...]
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2013-10-31 17:32:11 +08:00
|
|
|
|
2014-04-25 17:44:20 +08: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 20:12:40 +08:00
|
|
|
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
; CHECK: stp x29, x30, [sp, #-16]!
|
|
|
|
; CHECK: mov x29, sp
|
|
|
|
; CHECK: sub sp, sp, #192
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-DAG: stp q6, q7, [x29, #-96]
|
2014-04-14 20:50:58 +08:00
|
|
|
; [...]
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-DAG: stp q0, q1, [x29, #-192]
|
2014-04-14 20:50:58 +08:00
|
|
|
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-DAG: stp x5, x6, [x29, #-24]
|
2014-04-14 20:50:58 +08:00
|
|
|
; [...]
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-DAG: stp x1, x2, [x29, #-56]
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2014-04-25 17:44:20 +08:00
|
|
|
; CHECK-NOFP-ARM64: stp x29, x30, [sp, #-16]!
|
|
|
|
; CHECK-NOFP-ARM64: mov x29, sp
|
|
|
|
; CHECK-NOFP-ARM64: sub sp, sp, #64
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-NOFP-ARM64-DAG: stp x5, x6, [x29, #-24]
|
2014-04-25 17:44:20 +08:00
|
|
|
; [...]
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-NOFP-ARM64-DAG: stp x3, x4, [x29, #-40]
|
2014-04-25 17:44:20 +08:00
|
|
|
; [...]
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; CHECK-NOFP-ARM64-DAG: stp x1, x2, [x29, #-56]
|
2014-04-25 17:44:20 +08:00
|
|
|
; [...]
|
|
|
|
; CHECK-NOFP-ARM64: mov x8, sp
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2013-01-31 20:12:40 +08:00
|
|
|
%addr = alloca i8, i64 %n
|
|
|
|
|
|
|
|
call void @use_addr(i8* %addr)
|
|
|
|
; CHECK: bl use_addr
|
|
|
|
|
|
|
|
ret void
|
2013-10-31 17:32:11 +08:00
|
|
|
|
2014-04-25 17:44:20 +08: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 20:12:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_alloca_large_frame(i64 %n) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test_alloca_large_frame:
|
2016-02-13 00:31:41 +08:00
|
|
|
; CHECK-MACHO-LABEL: test_alloca_large_frame:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2014-04-14 20:50:58 +08:00
|
|
|
|
2019-08-16 23:42:28 +08:00
|
|
|
; CHECK: stp x29, x30, [sp, #-32]!
|
|
|
|
; CHECK: stp x28, x19, [sp, #16]
|
|
|
|
; CHECK: mov x29, sp
|
2014-05-24 20:50:23 +08:00
|
|
|
; CHECK: sub sp, sp, #1953, lsl #12
|
|
|
|
; CHECK: sub sp, sp, #512
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2016-02-13 00:31:41 +08:00
|
|
|
; CHECK-MACHO: stp x20, x19, [sp, #-32]!
|
|
|
|
; CHECK-MACHO: stp x29, x30, [sp, #16]
|
|
|
|
; CHECK-MACHO: add x29, sp, #16
|
|
|
|
; CHECK-MACHO: sub sp, sp, #1953, lsl #12
|
|
|
|
; CHECK-MACHO: sub sp, sp, #512
|
|
|
|
|
2013-01-31 20:12:40 +08: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 20:50:58 +08:00
|
|
|
|
2019-08-16 23:42:28 +08:00
|
|
|
; CHECK: mov sp, x29
|
|
|
|
; CHECK: ldp x28, x19, [sp, #16]
|
|
|
|
; CHECK: ldp x29, x30, [sp], #32
|
2016-02-13 00:31:41 +08:00
|
|
|
|
|
|
|
; CHECK-MACHO: sub sp, x29, #16
|
|
|
|
; CHECK-MACHO: ldp x29, x30, [sp, #16]
|
|
|
|
; CHECK-MACHO: ldp x20, x19, [sp], #32
|
2013-01-31 20:12:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
declare i8* @llvm.stacksave()
|
|
|
|
declare void @llvm.stackrestore(i8*)
|
|
|
|
|
|
|
|
define void @test_scoped_alloca(i64 %n) {
|
2013-10-09 15:53:57 +08:00
|
|
|
; CHECK-LABEL: test_scoped_alloca:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
%sp = call i8* @llvm.stacksave()
|
2019-08-16 23:42:28 +08:00
|
|
|
; CHECK: mov x29, sp
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: mov [[SAVED_SP:x[0-9]+]], sp
|
2013-10-09 15:53:57 +08:00
|
|
|
; CHECK: mov [[OLDSP:x[0-9]+]], sp
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
%addr = alloca i8, i64 %n
|
|
|
|
; CHECK: and [[SPDELTA:x[0-9]+]], {{x[0-9]+}}, #0xfffffffffffffff0
|
2013-10-09 15:53:57 +08:00
|
|
|
; CHECK-DAG: sub [[NEWSP:x[0-9]+]], [[OLDSP]], [[SPDELTA]]
|
2013-01-31 20:12:40 +08: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-27 02:56:54 +08:00
|
|
|
}
|