llvm-mirror/test/CodeGen/AArch64/addr-of-ret-addr.ll
Francis Visoiu Mistrih f7ea499702 Replace "no-frame-pointer-*" function attributes with "frame-pointer"
Part of the effort to refactoring frame pointer code generation. We used
to use two function attributes "no-frame-pointer-elim" and
"no-frame-pointer-elim-non-leaf" to represent three kinds of frame
pointer usage: (all) frames use frame pointer, (non-leaf) frames use
frame pointer, (none) frame use frame pointer. This CL makes the idea
explicit by using only one enum function attribute "frame-pointer"

Option "-frame-pointer=" replaces "-disable-fp-elim" for tools such as
llc.

"no-frame-pointer-elim" and "no-frame-pointer-elim-non-leaf" are still
supported for easy migration to "frame-pointer".

tests are mostly updated with

// replace command line args ‘-disable-fp-elim=false’ with ‘-frame-pointer=none’
grep -iIrnl '\-disable-fp-elim=false' * | xargs sed -i '' -e "s/-disable-fp-elim=false/-frame-pointer=none/g"

// replace command line args ‘-disable-fp-elim’ with ‘-frame-pointer=all’
grep -iIrnl '\-disable-fp-elim' * | xargs sed -i '' -e "s/-disable-fp-elim/-frame-pointer=all/g"

Patch by Yuanfang Chen (tabloid.adroit)!

Differential Revision: https://reviews.llvm.org/D56351

llvm-svn: 351049
2019-01-14 10:55:55 +00:00

52 lines
1.3 KiB
LLVM

; RUN: llc < %s -frame-pointer=all -mtriple=arm64-windows | FileCheck %s
; 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
; CHECK: str x1, [x29, #24]
; CHECK: add x1, x29, #8
; CHECK: ldp x29, x30, [sp, #16]
; CHECK: add sp, sp, #96
}