This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Functions that always return
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: Re: Functions that always return
- From: Richard Henderson <rth at cygnus dot com>
- Date: Sun, 29 Oct 2000 09:20:54 -0800
- Cc: gcc at gcc dot gnu dot org
- References: <10010291727.AA25871@vlsi1.ultra.nyu.edu>
On Sun, Oct 29, 2000 at 12:12:19PM -0500, Richard Kenner wrote:
> Well, so long as you don't mind if stuff that can potentially
> trap being moved across these functions. If you do care, you
> can't mark anything constant.
>
> Note the scenario here: an Ada procedure X calls a C++ function A,
> which calls a constant function B (also in C++) and B gets a stack
> overflow. That will cause a Storage_Error exception which, if caught
> at all, will be in X or above.
>
> Can you explain what you mean in conjuction with this scenario?
In conjunction with this scenario, I don't mean anything. Since
A is not constant, anything can happen.
The scenario I have in mind is a loop that contains a constant
function (with non-invariant arguments, so it doesn't get hoisted),
followed by, say, a division with invariant arguments. Since the
function is constant, it is "guaranteed to return", so the
division will "always" be executed, so we are allowed to hoist
it outside the loop.
If the function were not constant, we could not hoist the division
because the function might decide to terminate gracefully rather
than be killed by the division by zero that it knows is coming.
r~