This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix handling of call clobbering readonly-result
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Olivier Hainque <hainque at ACT-Europe dot FR>
- Cc: Richard dot Earnshaw at arm dot com, kenner at vlsi1 dot ultra dot nyu dot edu, gcc-patches at gcc dot gnu dot org
- Date: Thu, 08 May 2003 16:35:18 +0100
- Subject: Re: Fix handling of call clobbering readonly-result
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
>
> Richard Earnshaw wrote:
> > Simply build arm-elf cross compilers (--target=arm-elf) with and without
> > that patch (no need for an assembler). Then build the testcase using
> >
> > <gcc-build-dir>/gcc/cc1 -O2 -ffast-math -isystem <gcc-build-dir>
> > /gcc/include <gcc-src-dir>/gcc/testsuite/builtins-6.c
> >
> > Compare the assembly file differences (there rather obvious ;-)
>
> OK, thanks. There are indeed obvious differences, and I wonder if it could
> be a pre-patch latent bug exposed.
>
> Consider the following reduced testcase:
>
> int one ()
> {
> return 1;
> }
>
> int false (int x)
> {
> return 0;
> }
>
> int true ()
> {
> return one ();
> }
>
> int main()
> {
> int x;
>
> x = 80;
> if (false (x))
> abort ();
> if (! true ())
> abort ();
>
> x = 100;
> if (false (x))
> abort ();
> if (! true ())
> abort ();
>
> return 0;
> }
>
> Both compilers produce the output below, which does not seem quite right
> to me (second call to true() missing):
The second call to true can be eliminated because true() is a const
function (has no side-effects) -- put a breakpoint on
mark_const_function). The compiler has therefore noted that the result of
the first call can be used in place of the second, and what is more, that
abort() can never be called from the second point, because if it were, it
would have been called after the first call.
So I think the compiler has handled this particular example correctly.
R.