[LLVMdev] Exception handling question
Bill Wendling
wendling at apple.com
Thu Jan 21 15:58:22 PST 2010
On Jan 21, 2010, at 3:50 PM, James Williams wrote:
> Hi,
>
> I'm trying to get exception handling working in my compiler targetting LLVM. I've been working from the LLVM exception handling documentation (including http://llvm.org/docs/ExceptionHandling.html and http://wiki.llvm.org/HowTo:_Build_JIT_based_Exception_mechanism) and looking at g++-llvm's output.
>
> I've been trying to get a minimal test function to work, which simply invokes _Unwind_RaiseException with a single clean-up landing pad. However. when I run it my personality function is not getting called - _Unwind_RaiseException simply returns apparently doing nothing. Looking at the x86-64 assembly output from llc, I can see this is happening because the personality function is not getting into the DWARF eh table (the landing pad is there though).
>
> I'm stumped as to why not. I'd be grateful if anyone can point out what I'm doing wrong here:
>
> define i32 @_ZN4N0014Main5test5EN2IO6WriterEiA_l(%6*, %4*, i32, %33*) {
> entry:
> %err = alloca %4* ; <%4**> [#uses=1]
> %count = alloca i32 ; <i32*> [#uses=1]
> %e = alloca %33* ; <%33**> [#uses=2]
> %this = alloca %6* ; <%6**> [#uses=1]
> %.ex_value = alloca i8* ; <i8**> [#uses=1]
> %.ex_value_l = alloca i8* ; <i8**> [#uses=0]
> %.ex_type = alloca i64 ; <i64*> [#uses=1]
> br label %4
>
> ; <label>:4 ; preds = %entry
> store %6* %0, %6** %this
> store %4* %1, %4** %err
> store i32 %2, i32* %count
> store %33* %3, %33** %e
> br label %.try_body
>
> .try_body: ; preds = %4
> %5 = load %33** %e ; <%33*> [#uses=1]
> %6 = getelementptr inbounds %33* %5, i32 0, i32 2, i32 0 ; <i64*> [#uses=1]
> %7 = invoke i8* (...)* bitcast (i32 (%struct._Unwind_Exception*)* @_Unwind_RaiseException to i8* (...)*)(i64* %6)
> to label %8 unwind label %.finally_pad ; <i8*> [#uses=0]
>
> ; <label>:8 ; preds = %.try_body
> br label %.finally_handler
>
> .finally_pad: ; preds = %.try_body
> %9 = call i8* @llvm.eh.exception() ; <i8*> [#uses=2]
> store i8* %9, i8** %.ex_value
> %10 = call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8* %9, i8* bitcast (i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)* @__l_personality to i8*)) ; <i64> [#uses=1]
I think you'll need a "i8* null" at the end of this @llvm.eh.selector.i64 call.
-bw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100121/22ac72f3/attachment.html>
More information about the llvm-dev
mailing list