This is the mail archive of the gcc-bugs@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]

[Bug optimization/11635] New: [3.3/3.4 regression] Unnecessary store onto stack


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11635

           Summary: [3.3/3.4 regression] Unnecessary store onto stack
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-linux
  GCC host triplet: i386-linux
GCC target triplet: i386-linux

[forwarded from http://bugs.debian.org/202016]

seen in 3.2, 3,3 and current HEAD, "regression" from 2.95

#include <sys/socket.h>

int
main(void)
{
	struct sockaddr_storage from;
	struct sockaddr *const fromp = (void *)&from;
	socklen_t fromlen;

	fromlen = sizeof(from);
 
	if (getpeername(0, fromp, &fromlen) < 0) {
		return 1;
	}

	return 0;
}

If you compile it with

gcc -D_GNU_SOURCE -S -O2

you will get

        .file   "bug-202016.c"
        .text
        .p2align 2,,3
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        leal    -144(%ebp), %eax
        subl    $156, %esp
        leal    -136(%ebp), %edx
        pushl   %eax
        pushl   %edx
        pushl   $0
        movl    $128, -144(%ebp)
        movl    %edx, -140(%ebp)
        call    getpeername
        shrl    $31, %eax
        addl    $16, %esp
        leave
        ret
        .size   main, .-main
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4 20030722 (experimental)"


The store into -140(%ebp) is useless.

This does not occur if you remove the -D_GNU_SOURCE, so this is related
to the __SOCKADDR_ARG magic in sys/socket.h.  I can reproduce this with
gcc 3.2.  gcc 2.95 does not have this problem.


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