[llvm-commits] [llvm-gcc-4.2] r41171 - in /llvm-gcc-4.2/trunk/gcc: except.c except.h llvm-convert.cpp llvm-internal.h

Duncan Sands baldrick at free.fr
Sun Aug 19 23:19:55 PDT 2007


Hi Chris,

> > Exception handling rewrite - let gcc do the heavy
> > lifting.  This patch strips out the existing LLVM
> > eh code, and replaces it with simpler code that
> > exploits gcc's eh machinery.  It requires running
> > gcc's eh lowering pass (it was already being run
> > in gcc-4.2).  Not only is the new code simpler,
> > it also handles more cases correctly (essentially
> > all of the gcc eh tests) and results in better
> > quality bytecode.  In order to handle all of the
> > gcc tests correctly, some small tweaks need to be
> > made to the way LLVM handles the "nounwind"
> > attribute.  I plan to take care of this later.
> 
> Excellent!  Can you elaborate on what the nounwind change is?

I want to mark some function calls nounwind - this will be used
for calls in so-called no-throw regions and for calls to nothrow
functions (in the later case, the function itself can be marked
nounwind).  Next, if a call is marked nounwind, then the call
should not get an entry in the dwarf exception tables (this
causes the C++ personality function, i.e. the runtime, to
terminate the program if the call throws an exception).  Then
some changes need to be made to the optimizers: if a nounwind
call is inlined, then the nounwind attribute needs to be
propagated to any calls in the inlined function; also, if an
indirect nounwind call is resolved to a direct call to a non
nounwind function then the nounwind marking should not be lost
etc.  Probably some other attributes could do with this kind
of treatment too.

That said, this way of implementing nothrow may cause trouble
later when we try to support mixed language operation: suppose
that inlining causes an Ada function to perform a C++ nounwind
call.  The Ada personality won't terminate the program if that
routine does throw an exception, it will just keep on unwinding.
The essential problem is that nounwind does not require specifying
the (C++) personality, it is not an invoke.  [gcc also does not
use a personality for a function containing nothrow calls, unless
some other eh constructs are present].

Another implementation of nothrow would be to turn nothrow calls
into invokes with an empty filter and an explicit terminate call.
But that would fatten the bytecode plus it would cause a bunch of
extra dwarf stuff to be output, all to handle an obscure case.

My plan is to use nounwind for the moment, and worry about this
problem when we start work on handling multiple personality functions.

> Welcome back Duncan,

I'm still on holiday :)

Ciao,

Duncan.



More information about the llvm-commits mailing list