[LLVMdev] Darwin vs exceptions

Duncan Sands baldrick at free.fr
Sat Dec 8 00:48:18 PST 2007


Hi Dale,

> - Why was C++ claiming that every selector has a catch-all handler?

this is easy: because the semantics of invoke require it.  Yes, really.
If unwinding reaches an invoke then control is required to jump to the
unwind basic block.  At first I thought this probably wouldn't matter -
that it would be OK to not jump to the landing pad if the exception was
not being caught by it - and didn't implement it, but several eh failures
in the LLVM testsuite could be tracked down to it: the optimizers really
do exploit this property of invoke - it is quite subtle.  You typically see
it when code is massively inlined into one big flat main function.  Then I
tried to implement it by pushing a "cleanup" at the end of the exception
list.  But the unwinder treats cleanups specially, and ignores them if during
unwinding it only sees cleanups all the way up to the top - in short there
were testsuite failures with this approach.  So the only thing to do was
to push a catch-all on to the end of the list.

> The documentation above just says
> the C++ personality function will terminate the program if it detects  
> that unwinding the exception only results in matches with cleanups.
> Isn't that what's supposed to happen if there's no handler anywhere?

It is, and it is what will happen: with the current code you will unwind
into each landing pad and be rethrown until you get to the top.  Then the
program will be terminated.  Yes, this means that you get terminated slightly
more slowly than with gcc, however I don't see how to obtain correct invoke
semantics (and thus: correctly working programs) without it.

> - What is the right thing for Linux?  Is the deletion above safe there?

No, and it's not safe anywhere else either, though most of the time it
doesn't make any difference.

Ciao,

Duncan.



More information about the llvm-dev mailing list