1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -frame-pointer=all -mtriple=i686-- | FileCheck %s --check-prefix=i686
3; RUN: llc < %s -frame-pointer=all -mtriple=x86_64-- | FileCheck %s --check-prefix=x86_64
4
5define i8* @h() nounwind readnone optsize {
6; i686-LABEL: h:
7; i686:       # %bb.0: # %entry
8; i686-NEXT:    pushl %ebp
9; i686-NEXT:    movl %esp, %ebp
10; i686-NEXT:    movl (%ebp), %eax
11; i686-NEXT:    movl (%eax), %eax
12; i686-NEXT:    movl 4(%eax), %eax
13; i686-NEXT:    popl %ebp
14; i686-NEXT:    retl
15;
16; x86_64-LABEL: h:
17; x86_64:       # %bb.0: # %entry
18; x86_64-NEXT:    pushq %rbp
19; x86_64-NEXT:    movq %rsp, %rbp
20; x86_64-NEXT:    movq (%rbp), %rax
21; x86_64-NEXT:    movq (%rax), %rax
22; x86_64-NEXT:    movq 8(%rax), %rax
23; x86_64-NEXT:    popq %rbp
24; x86_64-NEXT:    retq
25entry:
26	%0 = tail call i8* @llvm.returnaddress(i32 2)		; <i8*> [#uses=1]
27	ret i8* %0
28}
29
30declare i8* @llvm.returnaddress(i32) nounwind readnone
31
32define i8* @g() nounwind readnone optsize {
33; i686-LABEL: g:
34; i686:       # %bb.0: # %entry
35; i686-NEXT:    pushl %ebp
36; i686-NEXT:    movl %esp, %ebp
37; i686-NEXT:    movl (%ebp), %eax
38; i686-NEXT:    movl 4(%eax), %eax
39; i686-NEXT:    popl %ebp
40; i686-NEXT:    retl
41;
42; x86_64-LABEL: g:
43; x86_64:       # %bb.0: # %entry
44; x86_64-NEXT:    pushq %rbp
45; x86_64-NEXT:    movq %rsp, %rbp
46; x86_64-NEXT:    movq (%rbp), %rax
47; x86_64-NEXT:    movq 8(%rax), %rax
48; x86_64-NEXT:    popq %rbp
49; x86_64-NEXT:    retq
50entry:
51	%0 = tail call i8* @llvm.returnaddress(i32 1)		; <i8*> [#uses=1]
52	ret i8* %0
53}
54
55define i8* @f() nounwind readnone optsize {
56; i686-LABEL: f:
57; i686:       # %bb.0: # %entry
58; i686-NEXT:    pushl %ebp
59; i686-NEXT:    movl %esp, %ebp
60; i686-NEXT:    movl 4(%ebp), %eax
61; i686-NEXT:    popl %ebp
62; i686-NEXT:    retl
63;
64; x86_64-LABEL: f:
65; x86_64:       # %bb.0: # %entry
66; x86_64-NEXT:    pushq %rbp
67; x86_64-NEXT:    movq %rsp, %rbp
68; x86_64-NEXT:    movq 8(%rbp), %rax
69; x86_64-NEXT:    popq %rbp
70; x86_64-NEXT:    retq
71entry:
72	%0 = tail call i8* @llvm.returnaddress(i32 0)		; <i8*> [#uses=1]
73	ret i8* %0
74}
75