the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / docs / ExceptionHandling.html
blob247448d2554e9975a901c6d4e8d4f48e99f66415
1 <!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 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <meta name="description"
8 content="Exception Handling in LLVM.">
9 <link rel="stylesheet" href="llvm.css" type="text/css">
10 </head>
12 <body>
14 <h1>Exception Handling in LLVM</h1>
16 <table class="layout" style="width:100%">
17 <tr class="layout">
18 <td class="left">
19 <ul>
20 <li><a href="#introduction">Introduction</a>
21 <ol>
22 <li><a href="#itanium">Itanium ABI Zero-cost Exception Handling</a></li>
23 <li><a href="#sjlj">Setjmp/Longjmp Exception Handling</a></li>
24 <li><a href="#overview">Overview</a></li>
25 </ol></li>
26 <li><a href="#codegen">LLVM Code Generation</a>
27 <ol>
28 <li><a href="#throw">Throw</a></li>
29 <li><a href="#try_catch">Try/Catch</a></li>
30 <li><a href="#cleanups">Cleanups</a></li>
31 <li><a href="#throw_filters">Throw Filters</a></li>
32 <li><a href="#restrictions">Restrictions</a></li>
33 </ol></li>
34 <li><a href="#format_common_intrinsics">Exception Handling Intrinsics</a>
35 <ol>
36 <li><a href="#llvm_eh_exception"><tt>llvm.eh.exception</tt></a></li>
37 <li><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a></li>
38 <li><a href="#llvm_eh_resume"><tt>llvm.eh.resume</tt></a></li>
39 <li><a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a></li>
40 <li><a href="#llvm_eh_sjlj_setjmp"><tt>llvm.eh.sjlj.setjmp</tt></a></li>
41 <li><a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a></li>
42 <li><a href="#llvm_eh_sjlj_lsda"><tt>llvm.eh.sjlj.lsda</tt></a></li>
43 <li><a href="#llvm_eh_sjlj_callsite"><tt>llvm.eh.sjlj.callsite</tt></a></li>
44 <li><a href="#llvm_eh_sjlj_dispatchsetup"><tt>llvm.eh.sjlj.dispatchsetup</tt></a></li>
45 </ol></li>
46 <li><a href="#asm">Asm Table Formats</a>
47 <ol>
48 <li><a href="#unwind_tables">Exception Handling Frame</a></li>
49 <li><a href="#exception_tables">Exception Tables</a></li>
50 </ol></li>
51 <li><a href="#todo">ToDo</a></li>
52 </ul>
53 </td>
54 </tr></table>
56 <div class="doc_author">
57 <p>Written by <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p>
58 </div>
61 <!-- *********************************************************************** -->
62 <h2><a name="introduction">Introduction</a></h2>
63 <!-- *********************************************************************** -->
65 <div>
67 <p>This document is the central repository for all information pertaining to
68 exception handling in LLVM. It describes the format that LLVM exception
69 handling information takes, which is useful for those interested in creating
70 front-ends or dealing directly with the information. Further, this document
71 provides specific examples of what exception handling information is used for
72 in C/C++.</p>
74 <!-- ======================================================================= -->
75 <h3>
76 <a name="itanium">Itanium ABI Zero-cost Exception Handling</a>
77 </h3>
79 <div>
81 <p>Exception handling for most programming languages is designed to recover from
82 conditions that rarely occur during general use of an application. To that
83 end, exception handling should not interfere with the main flow of an
84 application's algorithm by performing checkpointing tasks, such as saving the
85 current pc or register state.</p>
87 <p>The Itanium ABI Exception Handling Specification defines a methodology for
88 providing outlying data in the form of exception tables without inlining
89 speculative exception handling code in the flow of an application's main
90 algorithm. Thus, the specification is said to add "zero-cost" to the normal
91 execution of an application.</p>
93 <p>A more complete description of the Itanium ABI exception handling runtime
94 support of can be found at
95 <a href="http://www.codesourcery.com/cxx-abi/abi-eh.html">Itanium C++ ABI:
96 Exception Handling</a>. A description of the exception frame format can be
97 found at
98 <a href="http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html">Exception
99 Frames</a>, with details of the DWARF 3 specification at
100 <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3 Standard</a>.
101 A description for the C++ exception table formats can be found at
102 <a href="http://www.codesourcery.com/cxx-abi/exceptions.pdf">Exception Handling
103 Tables</a>.</p>
105 </div>
107 <!-- ======================================================================= -->
108 <h3>
109 <a name="sjlj">Setjmp/Longjmp Exception Handling</a>
110 </h3>
112 <div>
114 <p>Setjmp/Longjmp (SJLJ) based exception handling uses LLVM intrinsics
115 <a href="#llvm_eh_sjlj_setjmp"><tt>llvm.eh.sjlj.setjmp</tt></a> and
116 <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a> to
117 handle control flow for exception handling.</p>
119 <p>For each function which does exception processing, be it try/catch blocks
120 or cleanups, that function registers itself on a global frame list. When
121 exceptions are being unwound, the runtime uses this list to identify which
122 functions need processing.<p>
124 <p>Landing pad selection is encoded in the call site entry of the function
125 context. The runtime returns to the function via
126 <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a>, where
127 a switch table transfers control to the appropriate landing pad based on
128 the index stored in the function context.</p>
130 <p>In contrast to DWARF exception handling, which encodes exception regions
131 and frame information in out-of-line tables, SJLJ exception handling
132 builds and removes the unwind frame context at runtime. This results in
133 faster exception handling at the expense of slower execution when no
134 exceptions are thrown. As exceptions are, by their nature, intended for
135 uncommon code paths, DWARF exception handling is generally preferred to
136 SJLJ.</p>
137 </div>
139 <!-- ======================================================================= -->
140 <h3>
141 <a name="overview">Overview</a>
142 </h3>
144 <div>
146 <p>When an exception is thrown in LLVM code, the runtime does its best to find a
147 handler suited to processing the circumstance.</p>
149 <p>The runtime first attempts to find an <i>exception frame</i> corresponding to
150 the function where the exception was thrown. If the programming language
151 (e.g. C++) supports exception handling, the exception frame contains a
152 reference to an exception table describing how to process the exception. If
153 the language (e.g. C) does not support exception handling, or if the
154 exception needs to be forwarded to a prior activation, the exception frame
155 contains information about how to unwind the current activation and restore
156 the state of the prior activation. This process is repeated until the
157 exception is handled. If the exception is not handled and no activations
158 remain, then the application is terminated with an appropriate error
159 message.</p>
161 <p>Because different programming languages have different behaviors when
162 handling exceptions, the exception handling ABI provides a mechanism for
163 supplying <i>personalities.</i> An exception handling personality is defined
164 by way of a <i>personality function</i> (e.g. <tt>__gxx_personality_v0</tt>
165 in C++), which receives the context of the exception, an <i>exception
166 structure</i> containing the exception object type and value, and a reference
167 to the exception table for the current function. The personality function
168 for the current compile unit is specified in a <i>common exception
169 frame</i>.</p>
171 <p>The organization of an exception table is language dependent. For C++, an
172 exception table is organized as a series of code ranges defining what to do
173 if an exception occurs in that range. Typically, the information associated
174 with a range defines which types of exception objects (using C++ <i>type
175 info</i>) that are handled in that range, and an associated action that
176 should take place. Actions typically pass control to a <i>landing
177 pad</i>.</p>
179 <p>A landing pad corresponds to the code found in the <i>catch</i> portion of
180 a <i>try</i>/<i>catch</i> sequence. When execution resumes at a landing
181 pad, it receives the exception structure and a selector corresponding to
182 the <i>type</i> of exception thrown. The selector is then used to determine
183 which <i>catch</i> should actually process the exception.</p>
185 </div>
187 </div>
189 <!-- ======================================================================= -->
190 <h2>
191 <a name="codegen">LLVM Code Generation</a>
192 </h2>
194 <div>
196 <p>At the time of this writing, only C++ exception handling support is available
197 in LLVM. So the remainder of this document will be somewhat C++-centric.</p>
199 <p>From the C++ developers perspective, exceptions are defined in terms of the
200 <tt>throw</tt> and <tt>try</tt>/<tt>catch</tt> statements. In this section
201 we will describe the implementation of LLVM exception handling in terms of
202 C++ examples.</p>
204 <!-- ======================================================================= -->
205 <h3>
206 <a name="throw">Throw</a>
207 </h3>
209 <div>
211 <p>Languages that support exception handling typically provide a <tt>throw</tt>
212 operation to initiate the exception process. Internally, a throw operation
213 breaks down into two steps. First, a request is made to allocate exception
214 space for an exception structure. This structure needs to survive beyond the
215 current activation. This structure will contain the type and value of the
216 object being thrown. Second, a call is made to the runtime to raise the
217 exception, passing the exception structure as an argument.</p>
219 <p>In C++, the allocation of the exception structure is done by
220 the <tt>__cxa_allocate_exception</tt> runtime function. The exception
221 raising is handled by <tt>__cxa_throw</tt>. The type of the exception is
222 represented using a C++ RTTI structure.</p>
224 </div>
226 <!-- ======================================================================= -->
227 <h3>
228 <a name="try_catch">Try/Catch</a>
229 </h3>
231 <div>
233 <p>A call within the scope of a <i>try</i> statement can potentially raise an
234 exception. In those circumstances, the LLVM C++ front-end replaces the call
235 with an <tt>invoke</tt> instruction. Unlike a call, the <tt>invoke</tt> has
236 two potential continuation points: where to continue when the call succeeds
237 as per normal; and where to continue if the call raises an exception, either
238 by a throw or the unwinding of a throw.</p>
240 <p>The term used to define a the place where an <tt>invoke</tt> continues after
241 an exception is called a <i>landing pad</i>. LLVM landing pads are
242 conceptually alternative function entry points where an exception structure
243 reference and a type info index are passed in as arguments. The landing pad
244 saves the exception structure reference and then proceeds to select the catch
245 block that corresponds to the type info of the exception object.</p>
247 <p>Two LLVM intrinsic functions are used to convey information about the landing
248 pad to the back end.</p>
250 <ol>
251 <li><a href="#llvm_eh_exception"><tt>llvm.eh.exception</tt></a> takes no
252 arguments and returns a pointer to the exception structure. This only
253 returns a sensible value if called after an <tt>invoke</tt> has branched
254 to a landing pad. Due to code generation limitations, it must currently
255 be called in the landing pad itself.</li>
257 <li><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> takes a minimum
258 of three arguments. The first argument is the reference to the exception
259 structure. The second argument is a reference to the personality function
260 to be used for this <tt>try</tt>/<tt>catch</tt> sequence. Each of the
261 remaining arguments is either a reference to the type info for
262 a <tt>catch</tt> statement, a <a href="#throw_filters">filter</a>
263 expression, or the number zero (<tt>0</tt>) representing
264 a <a href="#cleanups">cleanup</a>. The exception is tested against the
265 arguments sequentially from first to last. The result of
266 the <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> is a
267 positive number if the exception matched a type info, a negative number if
268 it matched a filter, and zero if it matched a cleanup. If nothing is
269 matched, the behaviour of the program
270 is <a href="#restrictions">undefined</a>. This only returns a sensible
271 value if called after an <tt>invoke</tt> has branched to a landing pad.
272 Due to codegen limitations, it must currently be called in the landing pad
273 itself. If a type info matched, then the selector value is the index of
274 the type info in the exception table, which can be obtained using the
275 <a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a>
276 intrinsic.</li>
277 </ol>
279 <p>Once the landing pad has the type info selector, the code branches to the
280 code for the first catch. The catch then checks the value of the type info
281 selector against the index of type info for that catch. Since the type info
282 index is not known until all the type info have been gathered in the backend,
283 the catch code will call the
284 <a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic
285 to determine the index for a given type info. If the catch fails to match
286 the selector then control is passed on to the next catch. Note: Since the
287 landing pad will not be used if there is no match in the list of type info on
288 the call to <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>, then
289 neither the last catch nor <i>catch all</i> need to perform the check
290 against the selector.</p>
292 <p>Finally, the entry and exit of catch code is bracketed with calls
293 to <tt>__cxa_begin_catch</tt> and <tt>__cxa_end_catch</tt>.</p>
295 <ul>
296 <li><tt>__cxa_begin_catch</tt> takes a exception structure reference as an
297 argument and returns the value of the exception object.</li>
299 <li><tt>__cxa_end_catch</tt> takes no arguments. This function:<br><br>
300 <ol>
301 <li>Locates the most recently caught exception and decrements its handler
302 count,</li>
303 <li>Removes the exception from the "caught" stack if the handler count
304 goes to zero, and</li>
305 <li>Destroys the exception if the handler count goes to zero, and the
306 exception was not re-thrown by throw.</li>
307 </ol>
308 <p>Note: a rethrow from within the catch may replace this call with
309 a <tt>__cxa_rethrow</tt>.</p></li>
310 </ul>
312 </div>
314 <!-- ======================================================================= -->
315 <h3>
316 <a name="cleanups">Cleanups</a>
317 </h3>
319 <div>
321 <p>A cleanup is extra code which needs to be run as part of unwinding
322 a scope. C++ destructors are a prominent example, but other
323 languages and language extensions provide a variety of different
324 kinds of cleanup. In general, a landing pad may need to run
325 arbitrary amounts of cleanup code before actually entering a catch
326 block. To indicate the presence of cleanups, a landing pad's call
327 to <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> should
328 end with the argument <tt>i32 0</tt>; otherwise, the unwinder will
329 not stop at the landing pad if there are no catches or filters that
330 require it to.</p>
332 <p>Do not allow a new exception to propagate out of the execution of a
333 cleanup. This can corrupt the internal state of the unwinder.
334 Different languages describe different high-level semantics for
335 these situations: for example, C++ requires that the process be
336 terminated, whereas Ada cancels both exceptions and throws a third.</p>
338 <p>When all cleanups have completed, if the exception is not handled
339 by the current function, resume unwinding by calling the
340 <a href="#llvm_eh_resume"><tt>llvm.eh.resume</tt></a> intrinsic,
341 passing in the results of <tt>llvm.eh.exception</tt> and
342 <tt>llvm.eh.selector</tt> for the original landing pad.</p>
344 </div>
346 <!-- ======================================================================= -->
347 <h3>
348 <a name="throw_filters">Throw Filters</a>
349 </h3>
351 <div>
353 <p>C++ allows the specification of which exception types can be thrown from a
354 function. To represent this a top level landing pad may exist to filter out
355 invalid types. To express this in LLVM code the landing pad will
356 call <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The
357 arguments are a reference to the exception structure, a reference to the
358 personality function, the length of the filter expression (the number of type
359 infos plus one), followed by the type infos themselves.
360 <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> will return a
361 negative value if the exception does not match any of the type infos. If no
362 match is found then a call to <tt>__cxa_call_unexpected</tt> should be made,
363 otherwise <tt>_Unwind_Resume</tt>. Each of these functions requires a
364 reference to the exception structure. Note that the most general form of an
365 <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> call can contain
366 any number of type infos, filter expressions and cleanups (though having more
367 than one cleanup is pointless). The LLVM C++ front-end can generate such
368 <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> calls due to
369 inlining creating nested exception handling scopes.</p>
371 </div>
373 <!-- ======================================================================= -->
374 <h3>
375 <a name="restrictions">Restrictions</a>
376 </h3>
378 <div>
380 <p>The unwinder delegates the decision of whether to stop in a call
381 frame to that call frame's language-specific personality function.
382 Not all personalities functions guarantee that they will stop to
383 perform cleanups: for example, the GNU C++ personality doesn't do
384 so unless the exception is actually caught somewhere further up the
385 stack. When using this personality to implement EH for a language
386 that guarantees that cleanups will always be run, be sure to
387 indicate a catch-all in the
388 <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> call
389 rather than just cleanups.</p>
391 <p>In order for inlining to behave correctly, landing pads must be
392 prepared to handle selector results that they did not originally
393 advertise. Suppose that a function catches exceptions of
394 type <tt>A</tt>, and it's inlined into a function that catches
395 exceptions of type <tt>B</tt>. The inliner will update the
396 selector for the inlined landing pad to include the fact
397 that <tt>B</tt> is caught. If that landing pad assumes that it
398 will only be entered to catch an <tt>A</tt>, it's in for a rude
399 surprise. Consequently, landing pads must test for the selector
400 results they understand and then resume exception propagation
401 with the <a href="#llvm_eh_resume"><tt>llvm.eh.resume</tt></a>
402 intrinsic if none of the conditions match.</p>
404 </div>
406 </div>
408 <!-- ======================================================================= -->
409 <h2>
410 <a name="format_common_intrinsics">Exception Handling Intrinsics</a>
411 </h2>
413 <div>
415 <p>LLVM uses several intrinsic functions (name prefixed with "llvm.eh") to
416 provide exception handling information at various points in generated
417 code.</p>
419 <!-- ======================================================================= -->
420 <h4>
421 <a name="llvm_eh_exception">llvm.eh.exception</a>
422 </h4>
424 <div>
426 <pre>
427 i8* %<a href="#llvm_eh_exception">llvm.eh.exception</a>()
428 </pre>
430 <p>This intrinsic returns a pointer to the exception structure.</p>
432 </div>
434 <!-- ======================================================================= -->
435 <h4>
436 <a name="llvm_eh_selector">llvm.eh.selector</a>
437 </h4>
439 <div>
441 <pre>
442 i32 %<a href="#llvm_eh_selector">llvm.eh.selector</a>(i8*, i8*, ...)
443 </pre>
445 <p>This intrinsic is used to compare the exception with the given type infos,
446 filters and cleanups.</p>
448 <p><a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> takes a
449 minimum of three arguments. The first argument is the reference to
450 the exception structure. The second argument is a reference to the
451 personality function to be used for this try catch sequence. Each
452 of the remaining arguments is either a reference to the type info
453 for a catch statement, a <a href="#throw_filters">filter</a>
454 expression, or the number zero representing
455 a <a href="#cleanups">cleanup</a>. The exception is tested against
456 the arguments sequentially from first to last. The result of
457 the <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> is a
458 positive number if the exception matched a type info, a negative
459 number if it matched a filter, and zero if it matched a cleanup.
460 If nothing is matched, or if only a cleanup is matched, different
461 personality functions may or may not cause control to stop at the
462 landing pad; see <a href="#restrictions">the restrictions</a> for
463 more information. If a type info matched then the selector value
464 is the index of the type info in the exception table, which can be
465 obtained using the
466 <a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic.</p>
468 <p>If a landing pad containing a call to <tt>llvm.eh.selector</tt> is
469 inlined into an <tt>invoke</tt> instruction, the selector arguments
470 for the outer landing pad are appended to those of the inlined
471 landing pad. Consequently, landing pads must be written to ignore
472 selector values that they did not originally advertise.</p>
474 </div>
476 <!-- ======================================================================= -->
477 <h4>
478 <a name="llvm_eh_typeid_for">llvm.eh.typeid.for</a>
479 </h4>
481 <div>
483 <pre>
484 i32 %<a href="#llvm_eh_typeid_for">llvm.eh.typeid.for</a>(i8*)
485 </pre>
487 <p>This intrinsic returns the type info index in the exception table of the
488 current function. This value can be used to compare against the result
489 of <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The single
490 argument is a reference to a type info.</p>
492 </div>
494 <!-- ======================================================================= -->
495 <h4>
496 <a name="llvm_eh_resume">llvm.eh.resume</a>
497 </h4>
499 <div>
501 <pre>
502 void %<a href="#llvm_eh_resume">llvm.eh.resume</a>(i8*, i32) noreturn
503 </pre>
505 <p>This intrinsic is used to resume propagation of an exception after
506 landing at a landing pad. The first argument should be the result
507 of <a href="#llvm_eh_exception">llvm.eh.exception</a> for that
508 landing pad, and the second argument should be the result of
509 <a href="#llvm_eh_selector">llvm.eh.selector</a>. When a call to
510 this intrinsic is inlined into an invoke, the call is transformed
511 into a branch to the invoke's unwind destination, using its
512 arguments in place of the calls
513 to <a href="#llvm_eh_exception">llvm.eh.exception</a> and
514 <a href="#llvm_eh_selector">llvm.eh.selector</a> there.</p>
516 <p>This intrinsic is not implicitly <tt>nounwind</tt>; calls to it
517 will always throw. It may not be invoked.</p>
519 </div>
521 <!-- ======================================================================= -->
522 <h4>
523 <a name="llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a>
524 </h4>
526 <div>
528 <pre>
529 i32 %<a href="#llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a>(i8*)
530 </pre>
532 <p>The SJLJ exception handling uses this intrinsic to force register saving for
533 the current function and to store the address of the following instruction
534 for use as a destination address by <a href="#llvm_eh_sjlj_longjmp">
535 <tt>llvm.eh.sjlj.longjmp</tt></a>. The buffer format and the overall
536 functioning of this intrinsic is compatible with the GCC
537 <tt>__builtin_setjmp</tt> implementation, allowing code built with the
538 two compilers to interoperate.</p>
540 <p>The single parameter is a pointer to a five word buffer in which the calling
541 context is saved. The front end places the frame pointer in the first word,
542 and the target implementation of this intrinsic should place the destination
543 address for a
544 <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a> in the
545 second word. The following three words are available for use in a
546 target-specific manner.</p>
548 </div>
550 <!-- ======================================================================= -->
551 <h4>
552 <a name="llvm_eh_sjlj_longjmp">llvm.eh.sjlj.longjmp</a>
553 </h4>
555 <div>
557 <pre>
558 void %<a href="#llvm_eh_sjlj_longjmp">llvm.eh.sjlj.setjmp</a>(i8*)
559 </pre>
561 <p>The <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a>
562 intrinsic is used to implement <tt>__builtin_longjmp()</tt> for SJLJ
563 style exception handling. The single parameter is a pointer to a
564 buffer populated by <a href="#llvm_eh_sjlj_setjmp">
565 <tt>llvm.eh.sjlj.setjmp</tt></a>. The frame pointer and stack pointer
566 are restored from the buffer, then control is transferred to the
567 destination address.</p>
569 </div>
570 <!-- ======================================================================= -->
571 <h4>
572 <a name="llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a>
573 </h4>
575 <div>
577 <pre>
578 i8* %<a href="#llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a>()
579 </pre>
581 <p>Used for SJLJ based exception handling, the <a href="#llvm_eh_sjlj_lsda">
582 <tt>llvm.eh.sjlj.lsda</tt></a> intrinsic returns the address of the Language
583 Specific Data Area (LSDA) for the current function. The SJLJ front-end code
584 stores this address in the exception handling function context for use by the
585 runtime.</p>
587 </div>
589 <!-- ======================================================================= -->
590 <h4>
591 <a name="llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a>
592 </h4>
594 <div>
596 <pre>
597 void %<a href="#llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a>(i32)
598 </pre>
600 <p>For SJLJ based exception handling, the <a href="#llvm_eh_sjlj_callsite">
601 <tt>llvm.eh.sjlj.callsite</tt></a> intrinsic identifies the callsite value
602 associated with the following invoke instruction. This is used to ensure
603 that landing pad entries in the LSDA are generated in the matching order.</p>
605 </div>
607 <!-- ======================================================================= -->
608 <h4>
609 <a name="llvm_eh_sjlj_dispatchsetup">llvm.eh.sjlj.dispatchsetup</a>
610 </h4>
612 <div>
614 <pre>
615 void %<a href="#llvm_eh_sjlj_dispatchsetup">llvm.eh.sjlj.dispatchsetup</a>(i32)
616 </pre>
618 <p>For SJLJ based exception handling, the <a href="#llvm_eh_sjlj_dispatchsetup">
619 <tt>llvm.eh.sjlj.dispatchsetup</tt></a> intrinsic is used by targets to do
620 any unwind-edge setup they need. By default, no action is taken. </p>
622 </div>
624 </div>
626 <!-- ======================================================================= -->
627 <h2>
628 <a name="asm">Asm Table Formats</a>
629 </h2>
631 <div>
633 <p>There are two tables that are used by the exception handling runtime to
634 determine which actions should take place when an exception is thrown.</p>
636 <!-- ======================================================================= -->
637 <h3>
638 <a name="unwind_tables">Exception Handling Frame</a>
639 </h3>
641 <div>
643 <p>An exception handling frame <tt>eh_frame</tt> is very similar to the unwind
644 frame used by dwarf debug info. The frame contains all the information
645 necessary to tear down the current frame and restore the state of the prior
646 frame. There is an exception handling frame for each function in a compile
647 unit, plus a common exception handling frame that defines information common
648 to all functions in the unit.</p>
650 <p>Todo - Table details here.</p>
652 </div>
654 <!-- ======================================================================= -->
655 <h3>
656 <a name="exception_tables">Exception Tables</a>
657 </h3>
659 <div>
661 <p>An exception table contains information about what actions to take when an
662 exception is thrown in a particular part of a function's code. There is one
663 exception table per function except leaf routines and functions that have
664 only calls to non-throwing functions will not need an exception table.</p>
666 <p>Todo - Table details here.</p>
668 </div>
670 </div>
672 <!-- ======================================================================= -->
673 <h2>
674 <a name="todo">ToDo</a>
675 </h2>
677 <div>
679 <ol>
681 <li>Testing/Testing/Testing.</li>
683 </ol>
685 </div>
687 <!-- *********************************************************************** -->
689 <hr>
690 <address>
691 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
692 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
693 <a href="http://validator.w3.org/check/referer"><img
694 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
696 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
697 <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br>
698 Last modified: $Date$
699 </address>
701 </body>
702 </html>