[LLVMdev] RFC: Exception Handling Proposal Revised

Renato Golin rengolin at systemcall.org
Wed Dec 1 03:40:11 PST 2010


On 1 December 2010 11:11, Frits van Bommel <fvbommel at gmail.com> wrote:
> Those are destructor calls for the case where none of the foo()s
> throw. There are no ctor calls because the classes have trivial
> constructors, which are no-ops.

Indeed! Thanks! ;)


> If there were also catches, they'd probably need to explicitly execute
> the finally code (or if they again throw, have their unwind edges
> point to a dispatch with a catch-all to the finally code).

The problem is that, the code has to be run regardless of throwing or
not, but the exit of the finally block change depending on its
predecessor...

So either you have two identical blocks (like the clean-up code) or
you have a special way of defining the exit condition based on the
predecessor (like PHI nodes for EH, which is horrible!).

Example pseudo-IR:

try:
  invoke func() to label %finally unwind to %catch

catch:
  dispatch resume to %lpad
    catches [ ... ]

catch1:
  ...
  br %finally

lpad:
  br %finally (??)
  or cleanup code & continue unwinding?

finally:
  cleanup code
  return (or continue unwinding?)


cheers,
--renato



More information about the llvm-dev mailing list