[LLVMdev] RFC: Exception Handling Rewrite

Peter Lawrence peterl95124 at sbcglobal.net
Thu Aug 4 16:03:57 PDT 2011


Bill,
        I believe the empty-exception-specification example is a red- 
herring,
but that if you can construct an example where you think a landing-pad
requires multiple filter lists then I think we can then have a  
productive
conversation about it.

I believe we can only get multiple filter lists in a landing-pad if  
we attempt
to merge exception-regions, and since filters are only an outer-function
concept (not an inner try-statement concept) this can only come about
from function inlining.

so say we're considering inlining "void foo() throw(A) { ... }"  into
"void bar() throw (B) {...  foo(); ... ; frob(); ...}"

if you attempt to merge the landing pad for these functions (perhaps
assuming it is going to be simple because there are no cleanups in  
either
function that would complicate things) then...

there has to be a filter for A that will terminate the program if A  
is thrown,
but you cannot terminate the program if exception A comes from frob()
since it has not exception specification.


my conclusion is that you can only merge landing-pads if they already
have *identical* filters, so multiple filter lists isn't  
mathematically possible.

thoughts ?
comments ?

-Peter Lawrence.



PS.  I believe the empty-exception-specification example is a
red-herring because I believe you are making the same mistake that
everyone does concerning "exception specifications", which is assuming
they imply compile time correct information --  like "const" is  
enforced at
compile time  --  which is false  (and why exception specifications  
are a
bad design).


__attribute__((nothrow))  <--- user guarantee that the function
does not throw, the compiler is free to optimize based on this
assertion, and if the program violates that guarantee then the
the program is "undefined" and can "do anything".

throw()                                  <--- not a user guarantee of  
anything,
rather a user requirement that the compiler generate runtime checking
code to enforce that no exception is propagated out.












On Aug 4, 2011, at 3:20 PM, Bill Wendling wrote:

> On Aug 4, 2011, at 2:58 PM, Peter Lawrence wrote:
>
>> Bill,
>>        I suspect we're talking about two different aspects,
>> I think you are saying that there is an ability for the DWARF  
>> Actions Table
>> to contain multiple lists, including multiple filter lists - no  
>> disagreement
>> there,
>> I am saying that for any one landing-pad it might not make sense
>> for it to be able to have more than one filter list.
>>
> In general, it's not bad. But there is one problem, which your  
> example illustrates.
>
> 	void foo() throw() { /* ... */ }
>
> When "foo()" is inlined into its caller, the resulting function's  
> EH table should be set up to disallow exceptions thrown for the  
> inlined contents of foo(). Our current scheme is to mark foo() as  
> "nounwind" and make it a normal "call" instruction. Some care will  
> have to be taken during inlining to keep the "no throwing"  
> attribute around for the code that cares about it.
>
> -bw
>




More information about the llvm-dev mailing list