2019-01-14 18:55:55 +08:00
|
|
|
; RUN: llc < %s -frame-pointer=all -mtriple=arm64-windows | FileCheck %s
|
2018-11-02 05:23:47 +08:00
|
|
|
|
|
|
|
; Test generated from C code:
|
|
|
|
; #include <stdarg.h>
|
|
|
|
; void *foo() {
|
|
|
|
; return _AddressOfReturnAddress();
|
|
|
|
; }
|
|
|
|
; int bar(int x(va_list, void*), ...) {
|
|
|
|
; va_list y;
|
|
|
|
; va_start(y, x);
|
|
|
|
; return x(y, _AddressOfReturnAddress()) + 1;
|
|
|
|
; }
|
|
|
|
|
|
|
|
declare void @llvm.va_start(i8*)
|
|
|
|
declare i8* @llvm.addressofreturnaddress()
|
|
|
|
|
|
|
|
define dso_local i8* @"foo"() {
|
|
|
|
entry:
|
|
|
|
%0 = call i8* @llvm.addressofreturnaddress()
|
|
|
|
ret i8* %0
|
|
|
|
|
|
|
|
; CHECK-LABEL: foo
|
|
|
|
; CHECK: stp x29, x30, [sp, #-16]!
|
|
|
|
; CHECK: mov x29, sp
|
|
|
|
; CHECK: add x0, x29, #8
|
|
|
|
; CHECK: ldp x29, x30, [sp], #16
|
|
|
|
}
|
|
|
|
|
|
|
|
define dso_local i32 @"bar"(i32 (i8*, i8*)* %x, ...) {
|
|
|
|
entry:
|
|
|
|
%x.addr = alloca i32 (i8*, i8*)*, align 8
|
|
|
|
%y = alloca i8*, align 8
|
|
|
|
store i32 (i8*, i8*)* %x, i32 (i8*, i8*)** %x.addr, align 8
|
|
|
|
%y1 = bitcast i8** %y to i8*
|
|
|
|
call void @llvm.va_start(i8* %y1)
|
|
|
|
%0 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %x.addr, align 8
|
|
|
|
%1 = call i8* @llvm.addressofreturnaddress()
|
|
|
|
%2 = load i8*, i8** %y, align 8
|
|
|
|
%call = call i32 %0(i8* %2, i8* %1)
|
|
|
|
%add = add nsw i32 %call, 1
|
|
|
|
ret i32 %add
|
|
|
|
|
|
|
|
; CHECK-LABEL: bar
|
|
|
|
; CHECK: sub sp, sp, #96
|
|
|
|
; CHECK: stp x29, x30, [sp, #16]
|
|
|
|
; CHECK: add x29, sp, #16
|
[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: stp x1, x2, [x29, #24]
|
2018-11-02 05:23:47 +08:00
|
|
|
; CHECK: add x1, x29, #8
|
|
|
|
; CHECK: ldp x29, x30, [sp, #16]
|
|
|
|
; CHECK: add sp, sp, #96
|
|
|
|
}
|