public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marcovanotti15+gcc at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58744] Illegal Memory Access on 3-byte packed struct ARCH: x86_64
Date: Mon, 28 Oct 2013 22:32:00 -0000 [thread overview]
Message-ID: <bug-58744-4-1cTLVtPI0e@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58744-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58744
--- Comment #3 from Marco Vanotti <marcovanotti15+gcc at gmail dot com> ---
(In reply to Richard Biener from comment #2)
> Confirmed. On i?86 we properly do a 16byte and a 8byte access (but we copy
> to stack anyway).
>
Yes, if the value is passed on the stack, it gets copied right. (For example,
if it is the seventh parameter of a function, it will be passed on the stack
and will be copied right).
The thing is that in the x86_64 calling convention it has to be passed on
registers while the are available (rdi, rsi, rdx, rcx, r8 and r9).
Reading the source code, precisely the gcc/calls.c file:
http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/calls.c?revision=203967&view=markup
---
The params that are passed on the stack are handled in line 3027, which says:
/* Now store (and compute if necessary) all non-register parms.
These come before register parms, since they can require block-moves,
which could clobber the registers used for register parms.
Parms which have partial registers are not stored here,
but we do preallocate space here if they want that. */
Assuming that the registers may not require block-moves.
It uses the function "store_one_arg" to store the arg in the stack (it doesn't
work with a non-partial register).
---
After a while, the function "load_register_parameters" (line 1860) is called,
in this function, it falls in the case:
move_block_to_reg (REGNO (reg), mem, nregs, args[i].mode);
where nregs == 1.
So a whole register is copied.
---
I don't know how this issue should be fixed, should we copy the register into
pseudos before the "load_register_parameters" ? Or should we change the
move_block_to_reg function to make the right size of move instructions, for
x86_64 we don't need "backup-registers", but maybe this bug is also in another
arch.
size 3:
mov di, [rax]
sal rdi, 16
mov dil, [rax]
---
size 5:
mov edi, [rax]
sal rdi, 8
mov dil, [rax]
---
size 6:
mov edi, [rax]
sal rdi, 16
mov di, [rax]
---
size 7:
mov edi, [rax] ;move 4
sal rdi, 24
mov di, [rax] ;move 3
sal rdi, 16
mov dil, [rax]
-----------------------------
I would gladly submit a patch if I can get some advice on how this should be
fixed :)
next prev parent reply other threads:[~2013-10-28 22:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 4:18 [Bug c/58744] New: " marcovanotti15+gcc at gmail dot com
2013-10-16 4:23 ` [Bug c/58744] " marcovanotti15+gcc at gmail dot com
2013-10-23 11:49 ` [Bug target/58744] " rguenth at gcc dot gnu.org
2013-10-28 22:32 ` marcovanotti15+gcc at gmail dot com [this message]
2015-03-14 3:56 ` amodra at gmail dot com
2015-04-15 7:29 ` amodra at gcc dot gnu.org
2015-04-30 11:12 ` amodra at gcc dot gnu.org
2015-04-30 11:15 ` amodra at gmail dot com
2015-04-30 11:15 ` amodra at gmail dot com
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-58744-4-1cTLVtPI0e@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: link
Be 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).