public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Matthias Klose <doko@debian.org> To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org Subject: target/9080: optimisation on sparc leads to unalligned access in memcpy Date: Sat, 28 Dec 2002 05:56:00 -0000 [thread overview] Message-ID: <E18SHHs-0007va-00@tango.net.local> (raw) >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 <lists@lina.inka.de> >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:
next reply other threads:[~2002-12-28 13:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-28 5:56 Matthias Klose [this message] 2003-01-26 10:13 rth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=E18SHHs-0007va-00@tango.net.local \ --to=doko@debian.org \ --cc=136659@bugs.debian.org \ --cc=debian-gcc@lists.debian.org \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).