From: Duncan Sands
llvm.eh.selector takes a minimum of three arguments. The first argument is the reference to the exception structure. The second argument is a reference to the personality function to be -used for this try catch sequence. The remaining arguments are references to the -type infos for each of the catch statements in the order they should be tested. +used for this try catch sequence. Each of the remaining arguments is either a +reference to the type info for a catch statement, or a non-negative integer +followed by that many type info references, representing a +filter. +The exception is tested against the arguments sequentially from first to last. The catch all (...) is represented with a null i8*. The result -of the llvm.eh.selector is the index of -the type info in the corresponding exception table. The LLVM C++ front end -generates code to save this value in an alloca location for further use in the -landing pad and catch code.
+of the llvm.eh.selector is a positive +number if the exception matched a type info, a negative number if it matched a +filter, and zero if it didn't match anything. If a type info matched then the +returned value is the index of the type info in the exception table. +The LLVM C++ front end generates code to save this value in an alloca location +for further use in the landing pad and catch code.Once the landing pad has the type info selector, the code branches to the code for the first catch. The catch then checks the value of the type info @@ -268,12 +272,12 @@ constructor), there may be several landing pads for a given try.
C++ allows the specification of which exception types that can be thrown from a function. To represent this a top level landing pad may exist to filter out invalid types. To express this in LLVM code the landing pad will call llvm.eh.filter instead of llvm.eh.selector. The arguments are the -same, but what gets created in the exception table is different. llvm.eh.filter will return a negative value -if it doesn't find a match. If no match is found then a call to -__cxa_call_unexpected should be made, otherwise +number of different type infos the function may throw, followed by the type +infos themselves. +llvm.eh.selector will return a negative +value if the exception does not match any of the type infos. If no match is +found then a call to __cxa_call_unexpected should be made, otherwise _Unwind_Resume. Each of these functions require a reference to the exception structure.
@@ -326,32 +330,16 @@ exception selector.llvm.eh.selector takes a minimum of three arguments. The first argument is the reference to the exception structure. The second argument is a reference to the personality function to be -used for this try catch sequence. The remaining arguments are references to the -type infos for each of the catch statements in the order they should be tested. -The catch all (...) is represented with a null i8*.
- - - - -- i32 %llvm.eh.filter(i8*, i8*, i8*, ...) -- -
This intrinsic indicates that the exception selector is available at this -point in the code. The backend will replace this intrinsic with code to fetch -the second argument of a call. The effect is that the intrinsic result is the -exception selector.
- -llvm.eh.filter takes a minimum of -three arguments. The first argument is the reference to the exception -structure. The second argument is a reference to the personality function to be -used for this function. The remaining arguments are references to the type infos -for each type that can be thrown by the current function.
+used for this try catch sequence. Each of the remaining arguments is either a +reference to the type info for a catch statement, or a non-negative integer +followed by that many type info references, representing a +filter. +The exception is tested against the arguments sequentially from first to last. +The catch all (...) is represented with a null i8*. The result +of the llvm.eh.selector is a positive +number if the exception matched a type info, a negative number if it matched a +filter, and zero if it didn't match anything. If a type info matched then the +returned value is the index of the type info in the exception table.Need to create landing pads for code in between explicit landing pads. -The landing pads will have a zero action and a NULL landing pad address and are -used to inform the runtime that the exception should be rethrown.
Actions for a given function should be folded to save space.
Filters for inlined functions need to be handled more extensively. -Currently it's hardwired for one filter per function.
Testing/Testing/Testing.