public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mikpe at it dot uu dot se" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/42910] New: invalid memcpy() in trivial tail-call with large struct Date: Sat, 30 Jan 2010 23:28:00 -0000 [thread overview] Message-ID: <bug-42910-7665@http.gcc.gnu.org/bugzilla/> (raw) This is related to PR42909. When a tail-call does a trivial pass-through of a large struct, gcc generates a redundant block copy with identical source and destination addresses. On machines like x86 it inlines that as a rep;mov, but on others like m68k it generates a call to libc's memcpy(): > cat bug2.c struct s1 { int x[32]; }; extern void g1(struct s1); void f1(struct s1 s1) { g1(s1); } > m68k-unknown-linux-gcc -O2 -fomit-frame-pointer -S bug2.c > cat bug2.s #NO_APP .file "bug2.c" .text .align 2 .globl f1 .type f1, @function f1: move.l %sp,%d0 addq.l #4,%d0 pea 128.w move.l %d0,-(%sp) move.l %d0,-(%sp) jsr memcpy lea (12,%sp),%sp jra g1 .size f1, .-f1 .ident "GCC: (GNU) 4.5.0 20100128 (experimental)" .section .note.GNU-stack,"",@progbits However, formally speaking this triggers undefined behaviour as the memcpy's source and destination areas overlap. (Although the C standard does distinguish between inexact and exact overlap in assignments, there's no such distinction for library routines like memcpy.) -- Summary: invalid memcpy() in trivial tail-call with large struct Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikpe at it dot uu dot se GCC target triplet: m68k-unknown-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42910
next reply other threads:[~2010-01-30 23:28 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-01-30 23:28 mikpe at it dot uu dot se [this message] 2010-05-03 20:26 ` [Bug target/42910] " schwab at linux-m68k dot org
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=bug-42910-7665@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).