[LLVMdev] Unwinding through a native layer

Garrison Venn gvenn.cfe.dev at gmail.com
Mon Nov 23 10:13:57 PST 2009


Is it enough to know how to call libgcc's _Unwind_RaiseException, or is the code for invoke's exception block landing pad also not generated? After hacking to force in gcc_personaliy_v0(...) from the compiler-rt project (had to create an external dynamic C library), I'm able to get that called when an LLVM generated function (which was LLVM invoked), calls _Unwind_RaiseException (again via the same dynamic C lib). However as the default version of this personality does not check for handlers (I think this is the reason), the outer invoke's exception block is never entered. For a narrow non-mixed language interoperability focus, am I on the the right track--I don't think I want to use the C++ mechanism at least for learning purposes, or is there more code generation on the invoke side that needs to take place, and I therefore need to understand the likes of JITDwarfEmitter.cpp, and the code generation side of things? 

My eventual purpose here is to add exception like behavior to an LLVM generated version of a proprietary language runtime that I have. I guess I could also look at the PyPy project, but the "C++ ABI for Itanium: Exception Handling" implied something simple for just trying to do a simple unwind, as long as the invoke's exception landing pad was properly "registered". Sorry I'm vague here, but my understanding is even more vague at this point. :-)

Garrison

On Nov 19, 2009, at 3:38, Duncan Sands wrote:

> Reid Kleckner wrote:
>> On Wed, Nov 18, 2009 at 9:33 AM, Duncan Sands <baldrick at free.fr> wrote:
>>> Hi Garrison,
>>> 
>>>> - fc merely executes an unwind.
>>> the code generators do not know how to codegen unwind.  Only the
>>> interpreter has support for it.  Yes, this sucks.  You will need
>>> to call the libgcc unwind routine directly.
>> Really?  I thought the JIT supported exceptions via -enable-eh.
> 
> You mean by lowering to setjmp/longjmp?  Maybe, I don't know.
> It should be easy to find out by trying it.
> 
> Ciao,
> 
> Duncan.


On Nov 19, 2009, at 12:56, Reid Kleckner wrote:

>> You mean by lowering to setjmp/longjmp?  Maybe, I don't know.
>> It should be easy to find out by trying it.
> 
> No, with DWARF.  There's all this code in the JIT
> (JITDwarfEmitter.cpp) to register the DWARF with libgcc.
> 
> Reid





More information about the llvm-dev mailing list