Keeping unreachable code
Casper Hornstrup
chorns@users.sourceforge.net
Mon Feb 4 04:50:00 GMT 2002
On Monday 04 February 2002 13:07, you wrote:
> On Feb 3, 2002, Casper Hornstrup <chorns@users.sourceforge.net> wrote:
> > On Sunday 03 February 2002 23:37, you wrote:
> >> The compiler cannot throw away a function that could potentially be
> >> called from some other file.
> >
> > It can if it thinks it is 'dead' code and it does since no jumps targets
> > the code. The address of the exception handler is kept in a table so the
> > runtime library can find it.
>
> The difference is that a non-static function can be called from other
> translation units, so GCC has to keep in it, whereas a label is not be
> accessible from other translation units. GCC assumes labels are only
> reachable within the same function. The only exception is for
> non-local gotos from nested functions to labels in enclosing functions
> (a GCC extension), and exception handling. In the case of exception
> handling, the compiler creates edges from call insns to the
> corresponding handlers, such that they are not marked as dead. Just
> taking their addresses is not enough: there must be some live computed
> goto within the same function to mark labels whose addresses are taken
> as not dead. Consider doing something like:
>
> void *make_labels_live = 0;
>
> #define register_EH_label(label, where) do { \
> if (__builtin_expect(make_labels_live, 0)) goto *make_labels_live; \
> really_register_EH_label(&&label, where);
> } while (0)
>
>
> foo() {
> register_EH_label(my_eh_label, ???);
>
> ...
>
> my_eh_label:
> }
Thanks for the information.
So what are my options? 1) Put the label on the non-local goto labels list or
2) create edges. Since this is to be integrated with the current exception
handling implementation I prefer 2). Which function can I use to create these
edges with?
More information about the Gcc
mailing list