From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8743 invoked by alias); 28 Dec 2002 13:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 8716 invoked by uid 71); 28 Dec 2002 13:56:00 -0000 Resent-Date: 28 Dec 2002 13:56:00 -0000 Resent-Message-ID: <20021228135600.8715.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, Bernd Eckenfels Resent-Reply-To: gcc-gnats@gcc.gnu.org, 136659@bugs.debian.org Received: (qmail 1459 invoked from network); 28 Dec 2002 13:46:14 -0000 Received: from unknown (HELO hirsch.in-berlin.de) (192.109.42.6) by 209.249.29.67 with SMTP; 28 Dec 2002 13:46:14 -0000 Received: from tango.net.local (mail@dsl-213-023-039-145.arcor-ip.net [213.23.39.145]) (authenticated bits=0) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id gBSDk1XR007687 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Sat, 28 Dec 2002 14:46:01 +0100 Received: from doko by tango.net.local with local (Exim 4.12 #1 (Debian) [+araqnid]) id 18SHHs-0007va-00; Sat, 28 Dec 2002 14:46:00 +0100 Message-Id: Date: Sat, 28 Dec 2002 05:56:00 -0000 From: Matthias Klose Reply-To: 136659@bugs.debian.org To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: Bernd Eckenfels Subject: target/9080: optimisation on sparc leads to unalligned access in memcpy X-SW-Source: 2002-12/txt/msg01342.txt.bz2 List-Id: >Number: 9080 >Category: target >Synopsis: optimisation on sparc leads to unalligned access in memcpy >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sat Dec 28 05:56:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Bernd Eckenfels >Release: 3.2.1 (Debian) (Debian unstable) >Organization: The Debian Project >Environment: System: Debian GNU/Linux (unstable) Architecture: sparc host: sparc-linux gcc version 3.2.2 20021212 (Debian prerelease) >Description: [ Reported to the Debian BTS as report #136659. Please CC 136659@bugs.debian.org on replies. Log of report can be found at http://bugs.debian.org/136659 ] [ rechecked with gcc-3.2 CVS 20021212 ] To add to my problem (reported on debian devel) here is a test program to reproduce it: Output with o=2 (unaligned) ecki@auric:~$ ./bla Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset o=2 Now we are going to memcpy dst=a+x+o=0xeffffc7e result of a+x+o access: b=aaaabbbbbbbbbb Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc7e result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc7e Bus error Output with o=4 (aligned) ecki@auric:~$ gcc -O2 -o bla bla.c ecki@auric:~$ ./bla Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset o=4 Now we are going to memcpy dst=a+x+o=0xeffffc80 result of a+x+o access: b=aaaabbbbbbbbbb Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc80 result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc80 result of memcpy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb Note: in both cases the pointer to the target (of bcopy and memcpy) are the same a+x+o=0xeffffc7e and &(tmp_iphdr->saddr)=0xeffffc7e. The first case works with memcpy, the second doesnt. This looks clearly like some broken optimization. Indeed: ecki@auric:~$ gcc -O0 -o bla bla.c ecki@auric:~$ ./bla Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset o=2 Now we are going to memcpy dst=a+x+o=0xeffffc7e result of a+x+o access: b=aaaabbbbbbbbbb Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc7e result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc7e result of memcpy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: