Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 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> |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
Eric Christopher | 61f6978 | 2009-09-09 01:44:53 +0000 | [diff] [blame] | 7 | <meta name="description" |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 8 | content="Exception Handling in LLVM."> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 9 | <link rel="stylesheet" href="llvm.css" type="text/css"> |
| 10 | </head> |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 11 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 12 | <body> |
| 13 | |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 14 | <h1>Exception Handling in LLVM</h1> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 15 | |
| 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> |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 23 | <li><a href="#sjlj">Setjmp/Longjmp Exception Handling</a></li> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 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> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 30 | <li><a href="#cleanups">Cleanups</a></li> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 31 | <li><a href="#throw_filters">Throw Filters</a></li> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 32 | <li><a href="#restrictions">Restrictions</a></li> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 33 | </ol></li> |
Duncan Sands | 8036ca4 | 2007-03-30 12:22:09 +0000 | [diff] [blame] | 34 | <li><a href="#format_common_intrinsics">Exception Handling Intrinsics</a> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 35 | <ol> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 36 | <li><a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a></li> |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 37 | <li><a href="#llvm_eh_sjlj_setjmp"><tt>llvm.eh.sjlj.setjmp</tt></a></li> |
| 38 | <li><a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a></li> |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 39 | <li><a href="#llvm_eh_sjlj_lsda"><tt>llvm.eh.sjlj.lsda</tt></a></li> |
Jim Grosbach | ca752c9 | 2010-01-28 01:45:32 +0000 | [diff] [blame] | 40 | <li><a href="#llvm_eh_sjlj_callsite"><tt>llvm.eh.sjlj.callsite</tt></a></li> |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 41 | <li><a href="#llvm_eh_sjlj_dispatchsetup"><tt>llvm.eh.sjlj.dispatchsetup</tt></a></li> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 42 | </ol></li> |
| 43 | <li><a href="#asm">Asm Table Formats</a> |
| 44 | <ol> |
| 45 | <li><a href="#unwind_tables">Exception Handling Frame</a></li> |
| 46 | <li><a href="#exception_tables">Exception Tables</a></li> |
| 47 | </ol></li> |
| 48 | <li><a href="#todo">ToDo</a></li> |
| 49 | </ul> |
| 50 | </td> |
| 51 | </tr></table> |
| 52 | |
| 53 | <div class="doc_author"> |
| 54 | <p>Written by <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p> |
| 55 | </div> |
| 56 | |
| 57 | |
| 58 | <!-- *********************************************************************** --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 59 | <h2><a name="introduction">Introduction</a></h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 60 | <!-- *********************************************************************** --> |
| 61 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 62 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 63 | |
| 64 | <p>This document is the central repository for all information pertaining to |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 65 | exception handling in LLVM. It describes the format that LLVM exception |
| 66 | handling information takes, which is useful for those interested in creating |
| 67 | front-ends or dealing directly with the information. Further, this document |
| 68 | provides specific examples of what exception handling information is used for |
| 69 | in C/C++.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 70 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 71 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 72 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 73 | <a name="itanium">Itanium ABI Zero-cost Exception Handling</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 74 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 75 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 76 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 77 | |
| 78 | <p>Exception handling for most programming languages is designed to recover from |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 79 | conditions that rarely occur during general use of an application. To that |
| 80 | end, exception handling should not interfere with the main flow of an |
| 81 | application's algorithm by performing checkpointing tasks, such as saving the |
| 82 | current pc or register state.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 83 | |
| 84 | <p>The Itanium ABI Exception Handling Specification defines a methodology for |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 85 | providing outlying data in the form of exception tables without inlining |
| 86 | speculative exception handling code in the flow of an application's main |
| 87 | algorithm. Thus, the specification is said to add "zero-cost" to the normal |
| 88 | execution of an application.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 89 | |
| 90 | <p>A more complete description of the Itanium ABI exception handling runtime |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 91 | support of can be found at |
| 92 | <a href="http://www.codesourcery.com/cxx-abi/abi-eh.html">Itanium C++ ABI: |
| 93 | Exception Handling</a>. A description of the exception frame format can be |
| 94 | found at |
| 95 | <a href="http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html">Exception |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 96 | Frames</a>, with details of the DWARF 4 specification at |
| 97 | <a href="http://dwarfstd.org/Dwarf4Std.php">DWARF 4 Standard</a>. |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 98 | A description for the C++ exception table formats can be found at |
| 99 | <a href="http://www.codesourcery.com/cxx-abi/exceptions.pdf">Exception Handling |
| 100 | Tables</a>.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 101 | |
| 102 | </div> |
| 103 | |
| 104 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 105 | <h3> |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 106 | <a name="sjlj">Setjmp/Longjmp Exception Handling</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 107 | </h3> |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 108 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 109 | <div> |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 110 | |
| 111 | <p>Setjmp/Longjmp (SJLJ) based exception handling uses LLVM intrinsics |
| 112 | <a href="#llvm_eh_sjlj_setjmp"><tt>llvm.eh.sjlj.setjmp</tt></a> and |
| 113 | <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a> to |
| 114 | handle control flow for exception handling.</p> |
| 115 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 116 | <p>For each function which does exception processing — be |
| 117 | it <tt>try</tt>/<tt>catch</tt> blocks or cleanups — that function |
| 118 | registers itself on a global frame list. When exceptions are unwinding, the |
| 119 | runtime uses this list to identify which functions need processing.<p> |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 120 | |
| 121 | <p>Landing pad selection is encoded in the call site entry of the function |
| 122 | context. The runtime returns to the function via |
| 123 | <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a>, where |
| 124 | a switch table transfers control to the appropriate landing pad based on |
| 125 | the index stored in the function context.</p> |
| 126 | |
| 127 | <p>In contrast to DWARF exception handling, which encodes exception regions |
| 128 | and frame information in out-of-line tables, SJLJ exception handling |
| 129 | builds and removes the unwind frame context at runtime. This results in |
| 130 | faster exception handling at the expense of slower execution when no |
| 131 | exceptions are thrown. As exceptions are, by their nature, intended for |
| 132 | uncommon code paths, DWARF exception handling is generally preferred to |
| 133 | SJLJ.</p> |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 134 | |
Jim Grosbach | 00484d1 | 2009-08-22 01:42:39 +0000 | [diff] [blame] | 135 | </div> |
| 136 | |
| 137 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 138 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 139 | <a name="overview">Overview</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 140 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 141 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 142 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 143 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 144 | <p>When an exception is thrown in LLVM code, the runtime does its best to find a |
| 145 | handler suited to processing the circumstance.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 146 | |
| 147 | <p>The runtime first attempts to find an <i>exception frame</i> corresponding to |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 148 | the function where the exception was thrown. If the programming language |
| 149 | (e.g. C++) supports exception handling, the exception frame contains a |
| 150 | reference to an exception table describing how to process the exception. If |
| 151 | the language (e.g. C) does not support exception handling, or if the |
| 152 | exception needs to be forwarded to a prior activation, the exception frame |
| 153 | contains information about how to unwind the current activation and restore |
| 154 | the state of the prior activation. This process is repeated until the |
| 155 | exception is handled. If the exception is not handled and no activations |
| 156 | remain, then the application is terminated with an appropriate error |
| 157 | message.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 158 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 159 | <p>Because different programming languages have different behaviors when |
| 160 | handling exceptions, the exception handling ABI provides a mechanism for |
| 161 | supplying <i>personalities.</i> An exception handling personality is defined |
| 162 | by way of a <i>personality function</i> (e.g. <tt>__gxx_personality_v0</tt> |
| 163 | in C++), which receives the context of the exception, an <i>exception |
| 164 | structure</i> containing the exception object type and value, and a reference |
| 165 | to the exception table for the current function. The personality function |
| 166 | for the current compile unit is specified in a <i>common exception |
| 167 | frame</i>.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 168 | |
| 169 | <p>The organization of an exception table is language dependent. For C++, an |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 170 | exception table is organized as a series of code ranges defining what to do |
| 171 | if an exception occurs in that range. Typically, the information associated |
| 172 | with a range defines which types of exception objects (using C++ <i>type |
| 173 | info</i>) that are handled in that range, and an associated action that |
| 174 | should take place. Actions typically pass control to a <i>landing |
| 175 | pad</i>.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 176 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 177 | <p>A landing pad corresponds to the code found in the <tt>catch</tt> portion of |
| 178 | a <tt>try</tt>/<tt>catch</tt> sequence. When execution resumes at a landing |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 179 | pad, it receives the exception structure and a selector corresponding to |
| 180 | the <i>type</i> of exception thrown. The selector is then used to determine |
| 181 | which <i>catch</i> should actually process the exception.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 182 | |
| 183 | </div> |
| 184 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 185 | </div> |
| 186 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 187 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 188 | <h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 189 | <a name="codegen">LLVM Code Generation</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 190 | </h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 191 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 192 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 193 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 194 | <p>From the C++ developers perspective, exceptions are defined in terms of the |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 195 | <tt>throw</tt> and <tt>try</tt>/<tt>catch</tt> statements. In this section |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 196 | we will describe the implementation of LLVM exception handling in terms of |
| 197 | C++ examples.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 198 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 199 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 200 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 201 | <a name="throw">Throw</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 202 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 203 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 204 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 205 | |
| 206 | <p>Languages that support exception handling typically provide a <tt>throw</tt> |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 207 | operation to initiate the exception process. Internally, a throw operation |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 208 | breaks down into two steps.</p> |
| 209 | <ol> |
| 210 | <li>A request is made to allocate exception space for an exception structure. |
| 211 | This structure needs to survive beyond the current activation. This |
| 212 | structure will contain the type and value of the object being thrown.</li> |
| 213 | <li>A call is made to the runtime to raise the exception, passing the |
| 214 | exception structure as an argument.</li> |
| 215 | </ol> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 216 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 217 | <p>In C++, the allocation of the exception structure is done by then |
| 218 | <tt>__cxa_allocate_exception</tt> runtime function. The exception raising is |
| 219 | handled by <tt>__cxa_throw</tt>. The type of the exception is represented |
| 220 | using a C++ RTTI structure.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 221 | |
| 222 | </div> |
| 223 | |
| 224 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 225 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 226 | <a name="try_catch">Try/Catch</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 227 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 228 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 229 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 230 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 231 | <p>A call within the scope of a <i>try</i> statement can potentially raise an |
| 232 | exception. In those circumstances, the LLVM C++ front-end replaces the call |
| 233 | with an <tt>invoke</tt> instruction. Unlike a call, the <tt>invoke</tt> has |
| 234 | two potential continuation points: where to continue when the call succeeds |
| 235 | as per normal; and where to continue if the call raises an exception, either |
| 236 | by a throw or the unwinding of a throw.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 237 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 238 | <p>The term used to define a the place where an <tt>invoke</tt> continues after |
| 239 | an exception is called a <i>landing pad</i>. LLVM landing pads are |
| 240 | conceptually alternative function entry points where an exception structure |
| 241 | reference and a type info index are passed in as arguments. The landing pad |
| 242 | saves the exception structure reference and then proceeds to select the catch |
| 243 | block that corresponds to the type info of the exception object.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 244 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 245 | <p>The LLVM <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> |
| 246 | instruction</a> is used to convey information about the landing pad to the |
| 247 | back end. For C++, the <tt>landingpad</tt> instruction returns a pointer and |
| 248 | integer pair corresponding to the pointer to the exception structure and the |
| 249 | "selector value" respectively.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 250 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 251 | <p>The <tt>landingpad</tt> instruction takes a reference to the personality |
| 252 | function to be used for this <tt>try</tt>/<tt>catch</tt> sequence. The |
| 253 | remainder of the instruction is a list of <i>catch</i> and <i>filter</i> |
| 254 | clauses. The exception is tested against the clauses sequentially from first |
| 255 | to last. The selector value is a positive number if the exception matched a |
| 256 | type info, a negative number if it matched a filter, and zero if it matched a |
| 257 | cleanup. If nothing is matched, the behaviour of the program |
| 258 | is <a href="#restrictions">undefined</a>. If a type info matched, then the |
| 259 | selector value is the index of the type info in the exception table, which |
| 260 | can be obtained using the |
| 261 | <a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 262 | |
| 263 | <p>Once the landing pad has the type info selector, the code branches to the |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 264 | code for the first catch. The catch then checks the value of the type info |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 265 | selector against the index of type info for that catch. Since the type info |
| 266 | index is not known until all the type info have been gathered in the backend, |
| 267 | the catch code will call the |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 268 | <a href="#llvm_eh_typeid_for"><tt>llvm.eh.typeid.for</tt></a> intrinsic to |
| 269 | determine the index for a given type info. If the catch fails to match the |
| 270 | selector then control is passed on to the next catch. Note: Since the landing |
| 271 | pad will not be used if there is no match in the list of type info on the |
| 272 | call to the <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> |
| 273 | instruction</a>, then neither the last catch nor <i>catch all</i> need to |
| 274 | perform the check against the selector.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 275 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 276 | <p>Finally, the entry and exit of catch code is bracketed with calls |
| 277 | to <tt>__cxa_begin_catch</tt> and <tt>__cxa_end_catch</tt>.</p> |
| 278 | |
| 279 | <ul> |
| 280 | <li><tt>__cxa_begin_catch</tt> takes a exception structure reference as an |
| 281 | argument and returns the value of the exception object.</li> |
| 282 | |
Bill Wendling | 169e1b0 | 2009-09-10 22:14:16 +0000 | [diff] [blame] | 283 | <li><tt>__cxa_end_catch</tt> takes no arguments. This function:<br><br> |
| 284 | <ol> |
Bill Wendling | 808b9ce | 2009-09-10 22:12:50 +0000 | [diff] [blame] | 285 | <li>Locates the most recently caught exception and decrements its handler |
| 286 | count,</li> |
| 287 | <li>Removes the exception from the "caught" stack if the handler count |
| 288 | goes to zero, and</li> |
| 289 | <li>Destroys the exception if the handler count goes to zero, and the |
| 290 | exception was not re-thrown by throw.</li> |
Bill Wendling | 169e1b0 | 2009-09-10 22:14:16 +0000 | [diff] [blame] | 291 | </ol> |
Bill Wendling | 808b9ce | 2009-09-10 22:12:50 +0000 | [diff] [blame] | 292 | <p>Note: a rethrow from within the catch may replace this call with |
| 293 | a <tt>__cxa_rethrow</tt>.</p></li> |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 294 | </ul> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 295 | |
| 296 | </div> |
| 297 | |
| 298 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 299 | <h3> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 300 | <a name="cleanups">Cleanups</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 301 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 302 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 303 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 304 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 305 | <p>A cleanup is extra code which needs to be run as part of unwinding a scope. |
| 306 | C++ destructors are a prominent example, but other languages and language |
| 307 | extensions provide a variety of different kinds of cleanup. In general, a |
| 308 | landing pad may need to run arbitrary amounts of cleanup code before actually |
| 309 | entering a catch block. To indicate the presence of cleanups, a |
| 310 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instruction</a> |
| 311 | should have a <i>cleanup</i> clause. Otherwise, the unwinder will not stop at |
| 312 | the landing pad if there are no catches or filters that require it to.</p> |
John McCall | d7c1086 | 2011-05-28 07:45:59 +0000 | [diff] [blame] | 313 | |
| 314 | <p>Do not allow a new exception to propagate out of the execution of a |
| 315 | cleanup. This can corrupt the internal state of the unwinder. |
| 316 | Different languages describe different high-level semantics for |
| 317 | these situations: for example, C++ requires that the process be |
| 318 | terminated, whereas Ada cancels both exceptions and throws a third.</p> |
| 319 | |
| 320 | <p>When all cleanups have completed, if the exception is not handled |
| 321 | by the current function, resume unwinding by calling the |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 322 | <a href="LangRef.html#i_resume"><tt>resume</tt> instruction</a>, passing in |
| 323 | the results of the <tt>landingpad</tt> instruction for the original landing |
| 324 | pad.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 325 | |
| 326 | </div> |
| 327 | |
| 328 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 329 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 330 | <a name="throw_filters">Throw Filters</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 331 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 332 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 333 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 334 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 335 | <p>C++ allows the specification of which exception types can be thrown from a |
| 336 | function. To represent this a top level landing pad may exist to filter out |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 337 | invalid types. To express this in LLVM code the |
| 338 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instruction</a> will |
| 339 | have a filter clause. The clause consists of an array of type infos. |
| 340 | <tt>landingpad</tt> will return a negative value if the exception does not |
| 341 | match any of the type infos. If no match is found then a call |
| 342 | to <tt>__cxa_call_unexpected</tt> should be made, otherwise |
| 343 | <tt>_Unwind_Resume</tt>. Each of these functions requires a reference to the |
| 344 | exception structure. Note that the most general form of a |
| 345 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instruction</a> can |
| 346 | have any number of catch, cleanup, and filter clauses (though having more |
| 347 | than one cleanup is pointless). The LLVM C++ front-end can generate such |
| 348 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instructions</a> due |
| 349 | to inlining creating nested exception handling scopes.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 350 | |
| 351 | </div> |
| 352 | |
| 353 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 354 | <h3> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 355 | <a name="restrictions">Restrictions</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 356 | </h3> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 357 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 358 | <div> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 359 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 360 | <p>The unwinder delegates the decision of whether to stop in a call frame to |
| 361 | that call frame's language-specific personality function. Not all |
| 362 | personalities functions guarantee that they will stop to perform |
| 363 | cleanups. For example, the GNU C++ personality doesn't do so unless the |
| 364 | exception is actually caught somewhere further up the stack. When using this |
| 365 | personality to implement EH for a language that guarantees that cleanups will |
| 366 | always be run, be sure to indicate a catch-all in the |
| 367 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instruction</a> |
John McCall | d7c1086 | 2011-05-28 07:45:59 +0000 | [diff] [blame] | 368 | rather than just cleanups.</p> |
| 369 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 370 | <p>In order for inlining to behave correctly, landing pads must be prepared to |
| 371 | handle selector results that they did not originally advertise. Suppose that |
| 372 | a function catches exceptions of type <tt>A</tt>, and it's inlined into a |
| 373 | function that catches exceptions of type <tt>B</tt>. The inliner will update |
| 374 | the <tt>landingpad</tt> instruction for the inlined landing pad to include |
| 375 | the fact that <tt>B</tt> is caught. If that landing pad assumes that it will |
| 376 | only be entered to catch an <tt>A</tt>, it's in for a rude surprise. |
| 377 | Consequently, landing pads must test for the selector results they understand |
| 378 | and then resume exception propagation with the |
| 379 | <a href="LangRef.html#i_resume"><tt>resume</tt> instruction</a> if none of |
| 380 | the conditions match.</p> |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 381 | |
| 382 | </div> |
| 383 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 384 | </div> |
| 385 | |
Duncan Sands | 6590b04 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 386 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 387 | <h2> |
Duncan Sands | 8036ca4 | 2007-03-30 12:22:09 +0000 | [diff] [blame] | 388 | <a name="format_common_intrinsics">Exception Handling Intrinsics</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 389 | </h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 390 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 391 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 392 | |
Bill Wendling | 4a065dd | 2011-09-20 01:08:53 +0000 | [diff] [blame] | 393 | <p>In addition to the |
| 394 | <a href="LangRef.html#i_landingpad"><tt>landingpad</tt></a> and |
| 395 | <a href="LangRef.html#i_resume"><tt>resume</tt></a> instructions, LLVM uses |
| 396 | several intrinsic functions (name prefixed with "<tt>llvm.eh</tt>") to |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 397 | provide exception handling information at various points in generated |
| 398 | code.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 399 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 400 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 401 | <h4> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 402 | <a name="llvm_eh_typeid_for">llvm.eh.typeid.for</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 403 | </h4> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 404 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 405 | <div> |
Bill Wendling | bf230bf | 2009-08-15 20:08:04 +0000 | [diff] [blame] | 406 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 407 | <pre> |
Duncan Sands | b01bbdc | 2009-10-14 16:11:37 +0000 | [diff] [blame] | 408 | i32 %<a href="#llvm_eh_typeid_for">llvm.eh.typeid.for</a>(i8*) |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 409 | </pre> |
| 410 | |
| 411 | <p>This intrinsic returns the type info index in the exception table of the |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 412 | current function. This value can be used to compare against the result |
Bill Wendling | 3c05196 | 2011-09-20 01:14:54 +0000 | [diff] [blame] | 413 | of <a href="LangRef.html#i_landingpad"><tt>landingpad</tt> instruction</a>. |
| 414 | The single argument is a reference to a type info.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 415 | |
| 416 | </div> |
| 417 | |
| 418 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 419 | <h4> |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 420 | <a name="llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 421 | </h4> |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 422 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 423 | <div> |
Bill Wendling | 3cf4ffd | 2009-08-15 20:07:42 +0000 | [diff] [blame] | 424 | |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 425 | <pre> |
Bill Wendling | 3cf4ffd | 2009-08-15 20:07:42 +0000 | [diff] [blame] | 426 | i32 %<a href="#llvm_eh_sjlj_setjmp">llvm.eh.sjlj.setjmp</a>(i8*) |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 427 | </pre> |
| 428 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 429 | <p>The SJLJ exception handling uses this intrinsic to force register saving for |
| 430 | the current function and to store the address of the following instruction |
| 431 | for use as a destination address by <a href="#llvm_eh_sjlj_longjmp"> |
| 432 | <tt>llvm.eh.sjlj.longjmp</tt></a>. The buffer format and the overall |
| 433 | functioning of this intrinsic is compatible with the GCC |
| 434 | <tt>__builtin_setjmp</tt> implementation, allowing code built with the |
| 435 | two compilers to interoperate.</p> |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 436 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 437 | <p>The single parameter is a pointer to a five word buffer in which the calling |
| 438 | context is saved. The front end places the frame pointer in the first word, |
| 439 | and the target implementation of this intrinsic should place the destination |
| 440 | address for a |
| 441 | <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a> in the |
| 442 | second word. The following three words are available for use in a |
| 443 | target-specific manner.</p> |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 444 | |
Benjamin Kramer | e15192b | 2009-08-05 15:42:44 +0000 | [diff] [blame] | 445 | </div> |
| 446 | |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 447 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 448 | <h4> |
Jim Grosbach | 90346e2 | 2010-05-26 16:21:41 +0000 | [diff] [blame] | 449 | <a name="llvm_eh_sjlj_longjmp">llvm.eh.sjlj.longjmp</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 450 | </h4> |
Jim Grosbach | 90346e2 | 2010-05-26 16:21:41 +0000 | [diff] [blame] | 451 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 452 | <div> |
Jim Grosbach | 90346e2 | 2010-05-26 16:21:41 +0000 | [diff] [blame] | 453 | |
| 454 | <pre> |
| 455 | void %<a href="#llvm_eh_sjlj_longjmp">llvm.eh.sjlj.setjmp</a>(i8*) |
| 456 | </pre> |
| 457 | |
| 458 | <p>The <a href="#llvm_eh_sjlj_longjmp"><tt>llvm.eh.sjlj.longjmp</tt></a> |
| 459 | intrinsic is used to implement <tt>__builtin_longjmp()</tt> for SJLJ |
| 460 | style exception handling. The single parameter is a pointer to a |
| 461 | buffer populated by <a href="#llvm_eh_sjlj_setjmp"> |
| 462 | <tt>llvm.eh.sjlj.setjmp</tt></a>. The frame pointer and stack pointer |
Chris Lattner | 7a2bdde | 2011-04-15 05:18:47 +0000 | [diff] [blame] | 463 | are restored from the buffer, then control is transferred to the |
Jim Grosbach | 90346e2 | 2010-05-26 16:21:41 +0000 | [diff] [blame] | 464 | destination address.</p> |
| 465 | |
| 466 | </div> |
| 467 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 468 | <h4> |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 469 | <a name="llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 470 | </h4> |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 471 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 472 | <div> |
Bill Wendling | 3cf4ffd | 2009-08-15 20:07:42 +0000 | [diff] [blame] | 473 | |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 474 | <pre> |
Dan Gohman | 3dfb3cf | 2010-05-28 17:07:41 +0000 | [diff] [blame] | 475 | i8* %<a href="#llvm_eh_sjlj_lsda">llvm.eh.sjlj.lsda</a>() |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 476 | </pre> |
| 477 | |
| 478 | <p>Used for SJLJ based exception handling, the <a href="#llvm_eh_sjlj_lsda"> |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 479 | <tt>llvm.eh.sjlj.lsda</tt></a> intrinsic returns the address of the Language |
| 480 | Specific Data Area (LSDA) for the current function. The SJLJ front-end code |
| 481 | stores this address in the exception handling function context for use by the |
| 482 | runtime.</p> |
Jim Grosbach | 1b747ad | 2009-08-11 00:09:57 +0000 | [diff] [blame] | 483 | |
| 484 | </div> |
| 485 | |
| 486 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 487 | <h4> |
Jim Grosbach | ca752c9 | 2010-01-28 01:45:32 +0000 | [diff] [blame] | 488 | <a name="llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 489 | </h4> |
Jim Grosbach | ca752c9 | 2010-01-28 01:45:32 +0000 | [diff] [blame] | 490 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 491 | <div> |
Jim Grosbach | ca752c9 | 2010-01-28 01:45:32 +0000 | [diff] [blame] | 492 | |
| 493 | <pre> |
| 494 | void %<a href="#llvm_eh_sjlj_callsite">llvm.eh.sjlj.callsite</a>(i32) |
| 495 | </pre> |
| 496 | |
| 497 | <p>For SJLJ based exception handling, the <a href="#llvm_eh_sjlj_callsite"> |
| 498 | <tt>llvm.eh.sjlj.callsite</tt></a> intrinsic identifies the callsite value |
| 499 | associated with the following invoke instruction. This is used to ensure |
| 500 | that landing pad entries in the LSDA are generated in the matching order.</p> |
| 501 | |
| 502 | </div> |
| 503 | |
| 504 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 505 | <h4> |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 506 | <a name="llvm_eh_sjlj_dispatchsetup">llvm.eh.sjlj.dispatchsetup</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 507 | </h4> |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 508 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 509 | <div> |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 510 | |
| 511 | <pre> |
| 512 | void %<a href="#llvm_eh_sjlj_dispatchsetup">llvm.eh.sjlj.dispatchsetup</a>(i32) |
| 513 | </pre> |
| 514 | |
| 515 | <p>For SJLJ based exception handling, the <a href="#llvm_eh_sjlj_dispatchsetup"> |
| 516 | <tt>llvm.eh.sjlj.dispatchsetup</tt></a> intrinsic is used by targets to do |
| 517 | any unwind-edge setup they need. By default, no action is taken. </p> |
| 518 | |
| 519 | </div> |
| 520 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 521 | </div> |
| 522 | |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 523 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 524 | <h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 525 | <a name="asm">Asm Table Formats</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 526 | </h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 527 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 528 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 529 | |
| 530 | <p>There are two tables that are used by the exception handling runtime to |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 531 | determine which actions should take place when an exception is thrown.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 532 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 533 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 534 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 535 | <a name="unwind_tables">Exception Handling Frame</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 536 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 537 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 538 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 539 | |
| 540 | <p>An exception handling frame <tt>eh_frame</tt> is very similar to the unwind |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 541 | frame used by dwarf debug info. The frame contains all the information |
| 542 | necessary to tear down the current frame and restore the state of the prior |
| 543 | frame. There is an exception handling frame for each function in a compile |
| 544 | unit, plus a common exception handling frame that defines information common |
| 545 | to all functions in the unit.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 546 | |
| 547 | <p>Todo - Table details here.</p> |
| 548 | |
| 549 | </div> |
| 550 | |
| 551 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 552 | <h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 553 | <a name="exception_tables">Exception Tables</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 554 | </h3> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 555 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 556 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 557 | |
| 558 | <p>An exception table contains information about what actions to take when an |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 559 | exception is thrown in a particular part of a function's code. There is one |
| 560 | exception table per function except leaf routines and functions that have |
| 561 | only calls to non-throwing functions will not need an exception table.</p> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 562 | |
| 563 | <p>Todo - Table details here.</p> |
| 564 | |
| 565 | </div> |
| 566 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 567 | </div> |
| 568 | |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 569 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 570 | <h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 571 | <a name="todo">ToDo</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 572 | </h2> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 573 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 574 | <div> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 575 | |
| 576 | <ol> |
| 577 | |
Bill Wendling | c4f661e | 2009-08-15 08:56:09 +0000 | [diff] [blame] | 578 | <li>Testing/Testing/Testing.</li> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 579 | |
| 580 | </ol> |
| 581 | |
| 582 | </div> |
| 583 | |
| 584 | <!-- *********************************************************************** --> |
| 585 | |
| 586 | <hr> |
| 587 | <address> |
| 588 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 589 | src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 590 | <a href="http://validator.w3.org/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 591 | src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 592 | |
| 593 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> |
NAKAMURA Takumi | b9a3363 | 2011-04-09 02:13:37 +0000 | [diff] [blame] | 594 | <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br> |
Jim Laskey | d0d39b6 | 2007-03-14 19:29:42 +0000 | [diff] [blame] | 595 | Last modified: $Date$ |
| 596 | </address> |
| 597 | |
| 598 | </body> |
| 599 | </html> |