• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple i386-windows-gnu -exception-model sjlj -filetype asm -o - %s | FileCheck %s
2
3declare void @_Z20function_that_throwsv()
4declare i32 @__gxx_personality_sj0(...)
5declare i8* @__cxa_begin_catch(i8*)
6declare void @__cxa_end_catch()
7
8define void @_Z8functionv() personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) {
9entry:
10  invoke void @_Z20function_that_throwsv()
11          to label %try.cont unwind label %lpad
12
13lpad:
14  %0 = landingpad { i8*, i32 }
15          catch i8* null
16  %1 = extractvalue { i8*, i32 } %0, 0
17  %2 = tail call i8* @__cxa_begin_catch(i8* %1)
18  tail call void @__cxa_end_catch()
19  br label %try.cont
20
21try.cont:
22  ret void
23}
24
25;     struct _Unwind_FunctionContext {
26; +00   struct _Unwind_FunctionContext *prev;   -64(%ebp)
27; +04   uintptr_t __callsite;                   -60(%ebp)
28; +08   uintptr_t __buffer[4];                  -44(%ebp)
29; +28   __personality_routine __personality;    -40(%ebp)
30; +32   uintptr_t __lsda;                       -36(%ebp)
31; +36   void *__jbuf[];                         -32(%ebp)
32;     };
33
34
35; CHECK-LABEL: __Z8functionv:
36;     struct _Unwind_FunctionContext UFC;
37;
38;     UFC.__personality = __gxx_personality_sj0
39; CHECK: movl $___gxx_personality_sj0, -40(%ebp)
40;     UFC.__lsda = $LSDA
41; CHECK: movl $[[LSDA:GCC_except_table[0-9]+]], -36(%ebp)
42;     UFC.__jbuf[0] = $EBP
43; CHECK: movl %ebp, -32(%ebp)
44;     UFC.__jbuf[2] = $ESP
45; CHECK: movl %esp, -24(%ebp)
46;     UFC.__jbuf[1] = $EIP
47; CHECK: movl $[[RESUME:LBB[0-9]+_[0-9]+]], -28(%ebp)
48;     UFC.__callsite = 1
49; CHECK: movl $1, -60(%ebp)
50;     _Unwind_SjLj_Register(&UFC);
51; CHECK: leal -64(%ebp), %eax
52; CHECK: pushl %eax
53; CHECK: calll __Unwind_SjLj_Register
54; CHECK: addl $4, %esp
55;     function_that_throws();
56; CHECK: calll __Z20function_that_throwsv
57;     _Unwind_SjLj_Unregister(&UFC);
58; CHECK: leal -64(%ebp), %eax
59; CHECK: calll __Unwind_SjLj_Unregister
60;
61; CHECK: [[RESUME]]:
62; CHECK: leal -64(%ebp), %esi
63;     assert(UFC.__callsite <= 1);
64; CHECK: movl -60(%ebp), %eax
65; CHECK: cmpl $1, %eax
66; CHECK: jbe [[CONT:LBB[0-9]+_[0-9]+]]
67; CHECK: ud2
68; CHECK: [[CONT]]:
69;     *Handlers[--UFC.__callsite]
70; CHECK: subl $1, %eax
71; CHECK: jmpl *LJTI
72
73