1; RUN: llc -mtriple=x86_64-unknown-linux < %s | FileCheck -check-prefix X8664 %s
2; RUN: llc -mtriple=i686-unknown-linux < %s | FileCheck -check-prefix X8632 %s
3; Check that all callee-saved registers are saved and restored in functions
4; that call __builtin_unwind_init(). This is its undocumented behavior in gcc,
5; and it is used in compiling libgcc_eh.
6; See also PR8541
7
8declare void @llvm.eh.unwind.init()
9
10define void @calls_unwind_init() {
11  call void @llvm.eh.unwind.init()
12  ret void
13}
14
15; X8664-LABEL: calls_unwind_init:
16; X8664: pushq %rbp
17; X8664: pushq %r15
18; X8664: pushq %r14
19; X8664: pushq %r13
20; X8664: pushq %r12
21; X8664: pushq %rbx
22; X8664: popq %rbx
23; X8664: popq %r12
24; X8664: popq %r13
25; X8664: popq %r14
26; X8664: popq %r15
27
28; X8632-LABEL: calls_unwind_init:
29; X8632: pushl %ebp
30; X8632: pushl %ebx
31; X8632: pushl %edi
32; X8632: pushl %esi
33; X8632: popl %esi
34; X8632: popl %edi
35; X8632: popl %ebx
36; X8632: popl %ebp
37