Generate compact unwind encoding from CFI directives.
[oota-llvm.git] / test / CodeGen / X86 / compact-unwind.ll
1 ; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 | FileCheck -check-prefix=ASM %s
2 ; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -filetype=obj -o - \
3 ; RUN:  | llvm-objdump -triple x86_64-apple-darwin11 -s - \
4 ; RUN:  | FileCheck -check-prefix=CU %s
5
6 %ty = type { i8* }
7
8 @gv = external global i32
9
10 ; This is aligning the stack with a push of a random register.
11 ; ASM: pushq %rax
12
13 ; Even though we can't encode %rax into the compact unwind, We still want to be
14 ; able to generate a compact unwind encoding in this particular case.
15 ;
16 ; CU:      Contents of section __compact_unwind:
17 ; CU-NEXT: 0020 00000000 00000000 1e000000 01000101
18 ; CU-NEXT: 0030 00000000 00000000 00000000 00000000
19
20 define i8* @foo(i64 %size) {
21   %addr = alloca i64, align 8
22   %tmp20 = load i32* @gv, align 4
23   %tmp21 = call i32 @bar()
24   %tmp25 = load i64* %addr, align 8
25   %tmp26 = inttoptr i64 %tmp25 to %ty*
26   %tmp29 = getelementptr inbounds %ty* %tmp26, i64 0, i32 0
27   %tmp34 = load i8** %tmp29, align 8
28   %tmp35 = getelementptr inbounds i8* %tmp34, i64 %size
29   store i8* %tmp35, i8** %tmp29, align 8
30   ret i8* null
31 }
32
33 declare i32 @bar()