This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix handling of call clobbering readonly-result


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):

main:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, uses_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	mov	r0, #80
	sub	fp, ip, #4
	bl	false
	cmp	r0, #0
	bne	.L9
	bl	true
	cmp	r0, #0
	mov	r0, #100
	beq	.L9
	bl	false
	cmp	r0, #0
	ldmeqea	fp, {fp, sp, pc}
.L9:
	bl	abort
	.size	main, .-main


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]