This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Keeping unreachable code
- From: Casper Hornstrup <chorns at users dot sourceforge dot net>
- To: gcc at gcc dot gnu dot org
- Cc: "Robert Dewar <dewar at gnat dot com>; Richard Henderson" <rth at redhat dot com>
- Date: Sun, 3 Feb 2002 22:10:17 +0100
- Subject: Re: Keeping unreachable code
- References: <20020203185235.892A6F28EC@nile.gnat.com>
On Sunday 03 February 2002 19:52, you wrote:
> >>You don't. Put it in assembly outside the function where it belongs.
>
> or make it a separate public function
So GCC will not throw away a function that it cannot see is called from
anywhere? It is only a few instructions that is in this routine so I would
prefer to keep it in the function if possible. It could be as simple as:
movl $1, %eax
ret
Basicly, what I'm trying to do is to implement support in GCC for a form of
exception handling where the OS dispatches an exception to a runtime library
which then searches the stack for registered exception handlers and when one
is found, a filter routine is called (like the small routine above). The
filter routine determines if the exception handler will handle the exception
and reports this information back to the runtime library.
For example.
int test()
{
__try {
// Protected region
} __except (EXCEPTION_EXECUTE_HANDLER) {
// Exception handler
}
return 1;
}
EXCEPTION_EXECUTE_HANDLER is the filter routine - a constant that tells the
runtime library to call the start of the __except block in the event that an
exception occured (eg. an Access Violation). In the example above, if an
exception occur when inside the protected region, control is transferred to
the start of the exception handler. The __except block is executed and
then "return 1" is executed and the function return as it normally would.
GCC should generate a jump at the end of the __try block (it should jump to
just after the end of the __except block) because the __except block should
not be executed if no exception occur. This would cause GCC to throw away the
exception handler like it does with the filter routine now.
So here I cannot use a new function for the __except block since control
should flow normally out of the function even if an exception occur.
Isn't there any way to mark a block of code permanent?
Casper Hornstrup