[LLVMdev] Unwinds Gone Wild
Duncan Sands
baldrick at free.fr
Fri Sep 26 01:00:54 PDT 2008
> If you look at the generated x86 machine code, it looks like unwind is
> compiled into nothing at all:
Yes, unwind is currently not supported by the code generators. This is
bad, but not that easy to fix (hopefully one day...).
> I can't find any information about cxa_throw at all, not even a type
> signature. If I could, could I just call it as if it were unwind, and it
> would be caught by invoke?
cxa_throw comes from the gcc C++ runtime. In order to see how to throw
and catch things correctly using it, compile some C++ examples down to
bitcode using llvm-g++.
> This discovery is pretty disappointing ... I've been reading the LLVM
> documentation for a few days, and everything I've read led me to believe it
> had built-in exception handling. If unwind is supposed to work the way Marc
> and I are assuming, but in fact just compiles into nothing, then this really
> ought to be documented, and the assembler should give a warning or something
> if you use it. As it stands, there's no warning that the unwind instruction
> is totally being ignored (which is made particularly nasty because it's
> recognised as a block terminator, and therefore it allows successful
> compilation even when not followed by a ret instruction, where an empty
> statement would not).
The exception handling stuff needed by llvm-gcc is fully supported. Once that
was done I guess everyone took a breather and kind of forgot about unwind :)
I agree that it would be better to have the code generators abort if they see an
unwind.
> In the mean time, can anyone suggest a fix for Marc's dummy example which
> works in the current version of LLVM (even if it's platform specific)?
You currently have to use a gcc library routine. At some point cxa_throw
and the analogous routines for other languages end up calling _Unwind_RaiseException.
You may want to use that along with the C personality __gcc_personality_v0.
Ciao,
Duncan.
More information about the llvm-dev
mailing list