d594e9829942749747a056159cba58e94a6627a1
[oota-llvm.git] / test / CodeGen / X86 / sjlj.ll
1 ; RUN: llc < %s -mtriple=i386-pc-linux -mcpu=corei7 -relocation-model=static | FileCheck --check-prefix=X86 %s
2 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=corei7 | FileCheck --check-prefix=X64 %s
3
4 @buf = internal global [5 x i8*] zeroinitializer
5
6 declare i8* @llvm.frameaddress(i32) nounwind readnone
7
8 declare i8* @llvm.stacksave() nounwind
9
10 declare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind
11
12 declare void @llvm.eh.sjlj.longjmp(i8*) nounwind
13
14 define i32 @sj0() nounwind {
15   %fp = tail call i8* @llvm.frameaddress(i32 0)
16   store i8* %fp, i8** getelementptr inbounds ([5 x i8*]* @buf, i64 0, i64 0), align 16
17   %sp = tail call i8* @llvm.stacksave()
18   store i8* %sp, i8** getelementptr inbounds ([5 x i8*]* @buf, i64 0, i64 2), align 16
19   %r = tail call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
20   ret i32 %r
21 ; X86: sj0
22 ; x86: movl %ebp, buf
23 ; x86: movl ${{.*LBB.*}}, buf+4
24 ; X86: movl %esp, buf+8
25 ; X86: ret
26 ; X64: sj0
27 ; x64: movq %rbp, buf(%rip)
28 ; x64: movq ${{.*LBB.*}}, buf+8(%rip)
29 ; X64: movq %rsp, buf+16(%rip)
30 ; X64: ret
31 }
32
33 define void @lj0() nounwind {
34   tail call void @llvm.eh.sjlj.longjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
35   unreachable
36 ; X86: lj0
37 ; X86: movl buf, %ebp
38 ; X86: movl buf+4, %[[REG32:.*]]
39 ; X86: movl buf+8, %esp
40 ; X86: jmpl *%[[REG32]]
41 ; X64: lj0
42 ; X64: movq buf(%rip), %rbp
43 ; X64: movq buf+8(%rip), %[[REG64:.*]]
44 ; X64: movq buf+16(%rip), %rsp
45 ; X64: jmpq *%[[REG64]]
46 }