[LLVMdev] clang/g++ frontend: can __cxa_end_catch throw?

Duncan Sands baldrick at free.fr
Mon Jul 12 00:23:54 PDT 2010


Hi Yuri,

> When I compile a piece of C++ with exceptions into .ll I see that gcc
> frontend in some cases calls __cxa_end_catch with 'call' and in other
> cases with 'invoke' with termination in case of exception. clang++
> always just calls __cxa_end_catch with 'call' instruction.

IIRC, __cxa_end_catch may throw an exception because it runs the destructor
for the exception object, which can execute arbitrary user code and thus may
throw an exception.  This is why it is sometimes correct to use invoke for it.
However in the case of your example it seems that llvm-gcc didn't optimize the
code as well as it might, since the invoke is redundant.

Ciao,

Duncan.



More information about the llvm-dev mailing list