xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/sjlj.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=i386-pc-linux -mcpu=corei7 -relocation-model=static | FileCheck --check-prefix=X86 %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=i386-pc-linux -mcpu=corei7 -relocation-model=pic | FileCheck --check-prefix=PIC86 %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=corei7 -relocation-model=static | FileCheck --check-prefix=X64 %s
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=corei7 -relocation-model=pic | FileCheck --check-prefix=PIC64 %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker@buf = internal global [5 x i8*] zeroinitializer
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.frameaddress(i32) nounwind readnone
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.stacksave() nounwind
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.eh.sjlj.setjmp(i8*) nounwind
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.eh.sjlj.longjmp(i8*) nounwind
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine i32 @sj0() nounwind {
17*9880d681SAndroid Build Coastguard Worker  %fp = tail call i8* @llvm.frameaddress(i32 0)
18*9880d681SAndroid Build Coastguard Worker  store i8* %fp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 0), align 16
19*9880d681SAndroid Build Coastguard Worker  %sp = tail call i8* @llvm.stacksave()
20*9880d681SAndroid Build Coastguard Worker  store i8* %sp, i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @buf, i64 0, i64 2), align 16
21*9880d681SAndroid Build Coastguard Worker  %r = tail call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
22*9880d681SAndroid Build Coastguard Worker  ret i32 %r
23*9880d681SAndroid Build Coastguard Worker; X86: sj0
24*9880d681SAndroid Build Coastguard Worker; x86: movl %ebp, buf
25*9880d681SAndroid Build Coastguard Worker; X86: movl %esp, buf+8
26*9880d681SAndroid Build Coastguard Worker; x86: movl ${{.*LBB.*}}, buf+4
27*9880d681SAndroid Build Coastguard Worker; X86: ret
28*9880d681SAndroid Build Coastguard Worker; PIC86: sj0
29*9880d681SAndroid Build Coastguard Worker; PIC86: movl %ebp, buf@GOTOFF(%[[GOT:.*]])
30*9880d681SAndroid Build Coastguard Worker; PIC86: movl %esp, buf@GOTOFF+8(%[[GOT]])
31*9880d681SAndroid Build Coastguard Worker; PIC86: leal {{.*LBB.*}}@GOTOFF(%[[GOT]]), %[[LREG:.*]]
32*9880d681SAndroid Build Coastguard Worker; PIC86: movl %[[LREG]], buf@GOTOFF+4
33*9880d681SAndroid Build Coastguard Worker; PIC86: ret
34*9880d681SAndroid Build Coastguard Worker; X64: sj0
35*9880d681SAndroid Build Coastguard Worker; x64: movq %rbp, buf(%rip)
36*9880d681SAndroid Build Coastguard Worker; x64: movq ${{.*LBB.*}}, buf+8(%rip)
37*9880d681SAndroid Build Coastguard Worker; X64: movq %rsp, buf+16(%rip)
38*9880d681SAndroid Build Coastguard Worker; X64: ret
39*9880d681SAndroid Build Coastguard Worker; PIC64: sj0
40*9880d681SAndroid Build Coastguard Worker; PIC64: movq %rbp, buf(%rip)
41*9880d681SAndroid Build Coastguard Worker; PIC64: movq %rsp, buf+16(%rip)
42*9880d681SAndroid Build Coastguard Worker; PIC64: leaq {{.*LBB.*}}(%rip), %[[LREG:.*]]
43*9880d681SAndroid Build Coastguard Worker; PIC64: movq %[[LREG]], buf+8(%rip)
44*9880d681SAndroid Build Coastguard Worker; PIC64: ret
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdefine void @lj0() nounwind {
48*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.eh.sjlj.longjmp(i8* bitcast ([5 x i8*]* @buf to i8*))
49*9880d681SAndroid Build Coastguard Worker  unreachable
50*9880d681SAndroid Build Coastguard Worker; X86: lj0
51*9880d681SAndroid Build Coastguard Worker; X86: movl buf, %ebp
52*9880d681SAndroid Build Coastguard Worker; X86: movl buf+4, %[[REG32:.*]]
53*9880d681SAndroid Build Coastguard Worker; X86: movl buf+8, %esp
54*9880d681SAndroid Build Coastguard Worker; X86: jmpl *%[[REG32]]
55*9880d681SAndroid Build Coastguard Worker; X64: lj0
56*9880d681SAndroid Build Coastguard Worker; X64: movq buf(%rip), %rbp
57*9880d681SAndroid Build Coastguard Worker; X64: movq buf+8(%rip), %[[REG64:.*]]
58*9880d681SAndroid Build Coastguard Worker; X64: movq buf+16(%rip), %rsp
59*9880d681SAndroid Build Coastguard Worker; X64: jmpq *%[[REG64]]
60*9880d681SAndroid Build Coastguard Worker}
61