blob: 851ed1238be782e8375efb653379beb204b79e19 [file] [log] [blame]
Jim Laskeyd0d39b62007-03-14 19:29:42 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5 <title>Exception Handling in LLVM</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
7</head>
8<body>
9
10<div class="doc_title">Exception Handling in LLVM</div>
11
12<table class="layout" style="width:100%">
13 <tr class="layout">
14 <td class="left">
15<ul>
16 <li><a href="#introduction">Introduction</a>
17 <ol>
18 <li><a href="#itanium">Itanium ABI Zero-cost Exception Handling</a></li>
19 <li><a href="#overview">Overview</a></li>
20 </ol></li>
21 <li><a href="#codegen">LLVM Code Generation</a>
22 <ol>
23 <li><a href="#throw">Throw</a></li>
24 <li><a href="#try_catch">Try/Catch</a></li>
Duncan Sands6590b042007-08-27 15:47:50 +000025 <li><a href="#cleanups">Cleanups</a></li>
Jim Laskeyd0d39b62007-03-14 19:29:42 +000026 <li><a href="#throw_filters">Throw Filters</a></li>
Duncan Sands6590b042007-08-27 15:47:50 +000027 <li><a href="#restrictions">Restrictions</a></li>
Jim Laskeyd0d39b62007-03-14 19:29:42 +000028 </ol></li>
Duncan Sands8036ca42007-03-30 12:22:09 +000029 <li><a href="#format_common_intrinsics">Exception Handling Intrinsics</a>
Jim Laskeyd0d39b62007-03-14 19:29:42 +000030 <ol>
31 <li><a href="#llvm_eh_exception"><tt>llvm.eh.exception</tt></a></li>
32 <li><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a></li>
Jim Laskeyd0d39b62007-03-14 19:29:42 +000033 <li><a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a></li>
Jim Grosbachf9570122009-05-14 00:46:35 +000034 <li><a href="#llvm_eh_sjlj_setjmp"><tt>llvm.eh.sjlj.setjmp</tt></a></li>
35 <li><a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a></li>
Jim Grosbach1b747ad2009-08-11 00:09:57 +000036 <li><a href="#llvm_eh_sjlj_lsda"><tt>llvm.eh.sjlj.lsda</tt></a></li>
37 <li><a href="#llvm_eh_sjlj_callsite"><tt>llvm.eh.sjlj.callsite</tt></a></li>
Jim Laskeyd0d39b62007-03-14 19:29:42 +000038 </ol></li>
39 <li><a href="#asm">Asm Table Formats</a>
40 <ol>
41 <li><a href="#unwind_tables">Exception Handling Frame</a></li>
42 <li><a href="#exception_tables">Exception Tables</a></li>
43 </ol></li>
44 <li><a href="#todo">ToDo</a></li>
45</ul>
46</td>
47</tr></table>
48
49<div class="doc_author">
50 <p>Written by <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p>
51</div>
52
53
54<!-- *********************************************************************** -->
55<div class="doc_section"><a name="introduction">Introduction</a></div>
56<!-- *********************************************************************** -->
57
58<div class="doc_text">
59
60<p>This document is the central repository for all information pertaining to
61exception handling in LLVM. It describes the format that LLVM exception
62handling information takes, which is useful for those interested in creating
63front-ends or dealing directly with the information. Further, this document
64provides specific examples of what exception handling information is used for
65C/C++.</p>
66
67</div>
68
69<!-- ======================================================================= -->
70<div class="doc_subsection">
71 <a name="itanium">Itanium ABI Zero-cost Exception Handling</a>
72</div>
73
74<div class="doc_text">
75
76<p>Exception handling for most programming languages is designed to recover from
77conditions that rarely occur during general use of an application. To that end,
78exception handling should not interfere with the main flow of an
Bill Wendlingd40bc4a2007-09-22 10:17:08 +000079application's algorithm by performing checkpointing tasks such as saving
Jim Laskeyd0d39b62007-03-14 19:29:42 +000080the current pc or register state.</p>
81
82<p>The Itanium ABI Exception Handling Specification defines a methodology for
83providing outlying data in the form of exception tables without inlining
Bill Wendlingd40bc4a2007-09-22 10:17:08 +000084speculative exception handling code in the flow of an application's main
Jim Laskeyd0d39b62007-03-14 19:29:42 +000085algorithm. Thus, the specification is said to add "zero-cost" to the normal
86execution of an application.</p>
87
88<p>A more complete description of the Itanium ABI exception handling runtime
89support of can be found at <a
90href="http://www.codesourcery.com/cxx-abi/abi-eh.html">Itanium C++ ABI:
Bill Wendlingd40bc4a2007-09-22 10:17:08 +000091Exception Handling.</a> A description of the exception frame format can be found
92at <a href="http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-
Jim Laskeyd0d39b62007-03-14 19:29:42 +000093Core-generic/ehframechpt.html">Exception Frames</a>, with details of the Dwarf
94specification at <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">Dwarf 3
95Standard.</a> A description for the C++ exception table formats can be found at
96<a href="http://www.codesourcery.com/cxx-abi/exceptions.pdf">Exception Handling
97Tables.</a></p>
98
99</div>
100
101<!-- ======================================================================= -->
102<div class="doc_subsection">
103 <a name="overview">Overview</a>
104</div>
105
106<div class="doc_text">
107
108<p>When an exception is thrown in llvm code, the runtime does a best effort to
109find a handler suited to process the circumstance.</p>
110
111<p>The runtime first attempts to find an <i>exception frame</i> corresponding to
112the function where the exception was thrown. If the programming language (ex.
113C++) supports exception handling, the exception frame contains a reference to an
114exception table describing how to process the exception. If the language (ex.
115C) does not support exception handling or if the exception needs to be forwarded
116to a prior activation, the exception frame contains information about how to
117unwind the current activation and restore the state of the prior activation.
118This process is repeated until the exception is handled. If the exception is
119not handled and no activations remain, then the application is terminated with
120an appropriate error message.</p>
121
122<p>Since different programming languages have different behaviors when handling
123exceptions, the exception handling ABI provides a mechanism for supplying
124<i>personalities.</i> An exception handling personality is defined by way of a
125<i>personality function</i> (ex. for C++ <tt>__gxx_personality_v0</tt>) which
126receives the context of the exception, an <i>exception structure</i> containing
Duncan Sandsfb0a64a2007-04-16 13:02:27 +0000127the exception object type and value, and a reference to the exception table for
128the current function. The personality function for the current compile unit is
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000129specified in a <i>common exception frame</i>.</p>
130
131<p>The organization of an exception table is language dependent. For C++, an
132exception table is organized as a series of code ranges defining what to do if
133an exception occurs in that range. Typically, the information associated with a
134range defines which types of exception objects (using C++ <i>type info</i>) that
135are handled in that range, and an associated action that should take place.
136Actions typically pass control to a <i>landing pad</i>.</p>
137
138<p>A landing pad corresponds to the code found in the catch portion of a
139try/catch sequence. When execution resumes at a landing pad, it receives the
140exception structure and a selector corresponding to the <i>type</i> of exception
141thrown. The selector is then used to determine which catch should actually
142process the exception.</p>
143
144</div>
145
146<!-- ======================================================================= -->
147<div class="doc_section">
148 <a name="codegen">LLVM Code Generation</a>
149</div>
150
151<div class="doc_text">
152
153<p>At the time of this writing, only C++ exception handling support is available
154in LLVM. So the remainder of this document will be somewhat C++-centric.</p>
155
156<p>From the C++ developers perspective, exceptions are defined in terms of the
157<tt>throw</tt> and <tt>try/catch</tt> statements. In this section we will
158describe the implementation of llvm exception handling in terms of C++
159examples.</p>
160
161</div>
162
163<!-- ======================================================================= -->
164<div class="doc_subsection">
165 <a name="throw">Throw</a>
166</div>
167
168<div class="doc_text">
169
170<p>Languages that support exception handling typically provide a <tt>throw</tt>
171operation to initiate the exception process. Internally, a throw operation
172breaks down into two steps. First, a request is made to allocate exception
173space for an exception structure. This structure needs to survive beyond the
174current activation. This structure will contain the type and value of the
175object being thrown. Second, a call is made to the runtime to raise the
176exception, passing the exception structure as an argument.</p>
177
178<p>In C++, the allocation of the exception structure is done by the
179<tt>__cxa_allocate_exception</tt> runtime function. The exception raising is
180handled by <tt>__cxa_throw</tt>. The type of the exception is represented using
181a C++ RTTI type info structure.</p>
182
183</div>
184
185<!-- ======================================================================= -->
186<div class="doc_subsection">
187 <a name="try_catch">Try/Catch</a>
188</div>
189
190<div class="doc_text">
191
Duncan Sandsb0a1cbf2007-04-14 12:30:27 +0000192<p>A call within the scope of a try statement can potentially raise an exception.
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000193In those circumstances, the LLVM C++ front-end replaces the call with an
194<tt>invoke</tt> instruction. Unlike a call, the invoke has two potential
195continuation points; where to continue when the call succeeds as per normal, and
196where to continue if the call raises an exception, either by a throw or the
197unwinding of a throw.</p>
198
199<p>The term used to define a the place where an invoke continues after an
200exception is called a <i>landing pad</i>. LLVM landing pads are conceptually
Duncan Sandsfb0a64a2007-04-16 13:02:27 +0000201alternative function entry points where a exception structure reference and a type
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000202info index are passed in as arguments. The landing pad saves the exception
203structure reference and then proceeds to select the catch block that corresponds
204to the type info of the exception object.</p>
205
206<p>Two llvm intrinsic functions are used convey information about the landing
207pad to the back end.</p>
208
209<p><a href="#llvm_eh_exception"><tt>llvm.eh.exception</tt></a> takes no
Duncan Sands6531d472008-12-29 15:27:32 +0000210arguments and returns a pointer to the exception structure. This only returns a
211sensible value if called after an invoke has branched to a landing pad. Due to
212codegen limitations, it must currently be called in the landing pad itself.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000213
214<p><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> takes a minimum of
215three arguments. The first argument is the reference to the exception
216structure. The second argument is a reference to the personality function to be
Duncan Sandscf26d7c2007-07-04 20:52:51 +0000217used for this try catch sequence. Each of the remaining arguments is either a
Duncan Sands6590b042007-08-27 15:47:50 +0000218reference to the type info for a catch statement,
219a <a href="#throw_filters">filter</a> expression,
220or the number zero representing a <a href="#cleanups">cleanup</a>.
Duncan Sandscf26d7c2007-07-04 20:52:51 +0000221The exception is tested against the arguments sequentially from first to last.
Duncan Sands6590b042007-08-27 15:47:50 +0000222The result of the <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> is a
223positive number if the exception matched a type info, a negative number if it matched
224a filter, and zero if it matched a cleanup. If nothing is matched, the behaviour of
225the program is <a href="#restrictions">undefined</a>.
Duncan Sands6531d472008-12-29 15:27:32 +0000226This only returns a sensible value if called after an invoke has branched to a
227landing pad. Due to codegen limitations, it must currently be called in the
228landing pad itself.
Duncan Sands6590b042007-08-27 15:47:50 +0000229If a type info matched then the selector value is the index of the type info in
230the exception table, which can be obtained using the
231<a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000232
233<p>Once the landing pad has the type info selector, the code branches to the
234code for the first catch. The catch then checks the value of the type info
235selector against the index of type info for that catch. Since the type info
236index is not known until all the type info have been gathered in the backend,
237the catch code will call the <a
238href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic to
239determine the index for a given type info. If the catch fails to match the
240selector then control is passed on to the next catch. Note: Since the landing
241pad will not be used if there is no match in the list of type info on the call
242to <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>, then neither the
243last catch nor <i>catch all</i> need to perform the the check against the
244selector.</p>
245
246<p>Finally, the entry and exit of catch code is bracketed with calls to
247<tt>__cxa_begin_catch</tt> and <tt>__cxa_end_catch</tt>.
248<tt>__cxa_begin_catch</tt> takes a exception structure reference as an argument
Bill Wendlingd40bc4a2007-09-22 10:17:08 +0000249and returns the value of the exception object. <tt>__cxa_end_catch</tt>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000250takes a exception structure reference as an argument. This function clears the
251exception from the exception space. Note: a rethrow from within the catch may
252replace this call with a <tt>__cxa_rethrow</tt>.</p>
253
254</div>
255
256<!-- ======================================================================= -->
257<div class="doc_subsection">
Duncan Sands6590b042007-08-27 15:47:50 +0000258 <a name="cleanups">Cleanups</a>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000259</div>
260
261<div class="doc_text">
262
263<p>To handle destructors and cleanups in try code, control may not run directly
264from a landing pad to the first catch. Control may actually flow from the
265landing pad to clean up code and then to the first catch. Since the required
266clean up for each invoke in a try may be different (ex., intervening
Duncan Sands6590b042007-08-27 15:47:50 +0000267constructor), there may be several landing pads for a given try. If cleanups
268need to be run, the number zero should be passed as the last
269<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> argument.
270However for C++ a <tt>null i8*</tt> <a href="#restrictions">must</a> be passed
271instead.
272</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000273
274</div>
275
276<!-- ======================================================================= -->
277<div class="doc_subsection">
278 <a name="throw_filters">Throw Filters</a>
279</div>
280
281<div class="doc_text">
282
Duncan Sands6531d472008-12-29 15:27:32 +0000283<p>C++ allows the specification of which exception types can be thrown from
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000284a function. To represent this a top level landing pad may exist to filter out
285invalid types. To express this in LLVM code the landing pad will call <a
Duncan Sands6531d472008-12-29 15:27:32 +0000286href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The arguments are a
287reference to the exception structure, a reference to the personality function,
288the length of the filter expression (the number of type infos plus one),
289followed by the type infos themselves.
Duncan Sandscf26d7c2007-07-04 20:52:51 +0000290<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> will return a negative
291value if the exception does not match any of the type infos. If no match is
292found then a call to <tt>__cxa_call_unexpected</tt> should be made, otherwise
Duncan Sands6531d472008-12-29 15:27:32 +0000293<tt>_Unwind_Resume</tt>. Each of these functions requires a reference to the
294exception structure. Note that the most general form of an
295<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> call can contain
296any number of type infos, filter expressions and cleanups (though having more
297than one cleanup is pointless). The LLVM C++ front-end can generate such
298<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> calls due to inlining
299creating nested exception handling scopes.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000300
301</div>
302
303<!-- ======================================================================= -->
Duncan Sands6590b042007-08-27 15:47:50 +0000304<div class="doc_subsection">
305 <a name="restrictions">Restrictions</a>
306</div>
307
308<div class="doc_text">
309
310<p>The semantics of the invoke instruction require that any exception that
311unwinds through an invoke call should result in a branch to the invoke's unwind
312label. However such a branch will only happen if the
313<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> matches.
314Thus in order to ensure correct operation, the front-end must only generate
315<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> calls that are
316guaranteed to always match whatever exception unwinds through the invoke.
317For most languages it is enough to pass zero, indicating the presence of
318a <a href="#cleanups">cleanup</a>, as the last
319<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> argument.
320However for C++ this is not sufficient, because the C++ personality function
321will terminate the program if it detects that unwinding the exception only
322results in matches with cleanups. For C++ a <tt>null i8*</tt> should
323be passed as the last
324<a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> argument instead.
325This is interpreted as a catch-all by the C++ personality function, and will
326always match.
327</p>
328
329</div>
330
331<!-- ======================================================================= -->
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000332<div class="doc_section">
Duncan Sands8036ca42007-03-30 12:22:09 +0000333 <a name="format_common_intrinsics">Exception Handling Intrinsics</a>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000334</div>
335
336<div class="doc_text">
337
338<p>LLVM uses several intrinsic functions (name prefixed with "llvm.eh") to
339provide exception handling information at various points in generated code.</p>
340
341</div>
342
343<!-- ======================================================================= -->
344<div class="doc_subsubsection">
345 <a name="llvm_eh_exception">llvm.eh.exception</a>
346</div>
347
348<div class="doc_text">
349<pre>
350 i8* %<a href="#llvm_eh_exception">llvm.eh.exception</a>( )
351</pre>
352
Duncan Sands6531d472008-12-29 15:27:32 +0000353<p>This intrinsic returns a pointer to the exception structure.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000354
355</div>
356
357<!-- ======================================================================= -->
358<div class="doc_subsubsection">
359 <a name="llvm_eh_selector">llvm.eh.selector</a>
360</div>
361
362<div class="doc_text">
363<pre>
Anton Korobeynikov8806c7b2007-09-07 11:39:35 +0000364 i32 %<a href="#llvm_eh_selector">llvm.eh.selector.i32</a>(i8*, i8*, i8*, ...)
365 i64 %<a href="#llvm_eh_selector">llvm.eh.selector.i64</a>(i8*, i8*, i8*, ...)
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000366</pre>
367
Duncan Sands6531d472008-12-29 15:27:32 +0000368<p>This intrinsic is used to compare the exception with the given type infos,
369filters and cleanups.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000370
371<p><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> takes a minimum of
372three arguments. The first argument is the reference to the exception
373structure. The second argument is a reference to the personality function to be
Duncan Sands6590b042007-08-27 15:47:50 +0000374used for this try catch sequence. Each of the remaining arguments is either a
375reference to the type info for a catch statement,
376a <a href="#throw_filters">filter</a> expression,
377or the number zero representing a <a href="#cleanups">cleanup</a>.
Duncan Sandscf26d7c2007-07-04 20:52:51 +0000378The exception is tested against the arguments sequentially from first to last.
Duncan Sands6590b042007-08-27 15:47:50 +0000379The result of the <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> is a
380positive number if the exception matched a type info, a negative number if it matched
381a filter, and zero if it matched a cleanup. If nothing is matched, the behaviour of
382the program is <a href="#restrictions">undefined</a>.
383If a type info matched then the selector value is the index of the type info in
384the exception table, which can be obtained using the
385<a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic.</p>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000386
387</div>
388
389<!-- ======================================================================= -->
390<div class="doc_subsubsection">
391 <a name="llvm_eh_typeid_for">llvm.eh.typeid.for</a>
392</div>
393
394<div class="doc_text">
395<pre>
Anton Korobeynikov8806c7b2007-09-07 11:39:35 +0000396 i32 %<a href="#llvm_eh_typeid_for">llvm.eh.typeid.for.i32</a>(i8*)
397 i64 %<a href="#llvm_eh_typeid_for">llvm.eh.typeid.for.i64</a>(i8*)
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000398</pre>
399
400<p>This intrinsic returns the type info index in the exception table of the
401current function. This value can be used to compare against the result of <a
402href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The single argument is
403a reference to a type info.</p>
404
405</div>
406
407<!-- ======================================================================= -->
Jim Grosbachf9570122009-05-14 00:46:35 +0000408<div class="doc_subsubsection">
409 <a name="llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a>
410</div>
411
412<div class="doc_text">
413<pre>
414 i32 %<a href="#llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a>(i8*)
415</pre>
416
417<p>The SJLJ exception handling uses this intrinsic to force register saving
418for the current function and to store the address of the following instruction
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000419for use as a destination address by <a href="#llvm_eh_sjlj_longjmp">
Jim Grosbachf9570122009-05-14 00:46:35 +0000420<tt>llvm.eh.sjlj.longjmp</tt></a>. The buffer format and the overall functioning
Jim Grosbach06261cd2009-05-14 15:44:15 +0000421of this intrinsic is compatible with the GCC <tt>__builtin_setjmp</tt>
422implementation, allowing code built with the two compilers to interoperate.</p>
Jim Grosbachf9570122009-05-14 00:46:35 +0000423
424<p>The single parameter is a pointer to a five word buffer in which the
425calling context is saved. The front end places the frame pointer in the
426first word, and the target implementation of this intrinsic should place the
427destination address for a <a href="#llvm_eh_sjlj_longjmp"><tt>
Jim Grosbach06261cd2009-05-14 15:44:15 +0000428llvm.eh.sjlj.longjmp</tt></a> in the second word. The following three words
429are available for use in a target-specific manner.</p>
Jim Grosbachf9570122009-05-14 00:46:35 +0000430
Benjamin Kramere15192b2009-08-05 15:42:44 +0000431</div>
432
Jim Grosbachf9570122009-05-14 00:46:35 +0000433<!-- ======================================================================= -->
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000434<div class="doc_subsubsection">
435 <a name="llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a>
436</div>
437
438<div class="doc_text">
439<pre>
440 i8* %<a href="#llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a>( )
441</pre>
442
443<p>Used for SJLJ based exception handling, the <a href="#llvm_eh_sjlj_lsda">
444 <tt>llvm.eh.sjlj.lsda</tt></a> intrinsic returns the address of the Language
445Specific Data Area (LSDA) for the current function. The SJLJ front-end code
446stores this address in the exception handling function context for use by
447the runtime.</p>
448
449</div>
450
451<!-- ======================================================================= -->
452<div class="doc_subsubsection">
453 <a name="llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a>
454</div>
455
456<div class="doc_text">
457<pre>
458 void %<a href="#llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a>(i32)
459</pre>
460
461<p>The SJLJ front-end allocates call site indices for invoke instrucitons.
462These values are passed to the back-end via the
463<a href="#llvm_eh_sjlj_callsite"><tt>llvm.eh.sjlj.callsite</tt></a>
464intrinsic, where they are used to build the LSDA call-site table.</p>
465
466</div>
467
468<!-- ======================================================================= -->
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000469<div class="doc_section">
470 <a name="asm">Asm Table Formats</a>
471</div>
472
473<div class="doc_text">
474
475<p>There are two tables that are used by the exception handling runtime to
476determine which actions should take place when an exception is thrown.</p>
477
478</div>
479
480<!-- ======================================================================= -->
481<div class="doc_subsection">
482 <a name="unwind_tables">Exception Handling Frame</a>
483</div>
484
485<div class="doc_text">
486
487<p>An exception handling frame <tt>eh_frame</tt> is very similar to the unwind
488frame used by dwarf debug info. The frame contains all the information
489necessary to tear down the current frame and restore the state of the prior
490frame. There is an exception handling frame for each function in a compile
491unit, plus a common exception handling frame that defines information common to
492all functions in the unit.</p>
493
494<p>Todo - Table details here.</p>
495
496</div>
497
498<!-- ======================================================================= -->
499<div class="doc_subsection">
500 <a name="exception_tables">Exception Tables</a>
501</div>
502
503<div class="doc_text">
504
505<p>An exception table contains information about what actions to take when an
Bill Wendlingd40bc4a2007-09-22 10:17:08 +0000506exception is thrown in a particular part of a function's code. There is
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000507one exception table per function except leaf routines and functions that have
508only calls to non-throwing functions will not need an exception table.</p>
509
510<p>Todo - Table details here.</p>
511
512</div>
513
514<!-- ======================================================================= -->
515<div class="doc_section">
516 <a name="todo">ToDo</a>
517</div>
518
519<div class="doc_text">
520
521<ol>
522
Bill Wendlingd40bc4a2007-09-22 10:17:08 +0000523<li><p>Testing/Testing/Testing.</p></li>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000524
525</ol>
526
527</div>
528
529<!-- *********************************************************************** -->
530
531<hr>
532<address>
533 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000534 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000535 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000536 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Jim Laskeyd0d39b62007-03-14 19:29:42 +0000537
538 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
539 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
540 Last modified: $Date$
541</address>
542
543</body>
544</html>