public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>,
	Richard Biener <rguenther@suse.de>
Subject: Re: [arm][RFC] PR target/88469 fix incorrect argument passing with 64-bit bitfields
Date: Fri, 01 Mar 2019 10:03:00 -0000	[thread overview]
Message-ID: <fcfc2624-5089-915d-20c6-b9f3f3eb93f2@arm.com> (raw)
In-Reply-To: <AM6PR07MB40372CBF71330ECF2B20A7ECE4750@AM6PR07MB4037.eurprd07.prod.outlook.com>

On 28/02/2019 14:51, Bernd Edlinger wrote:
> On 2/28/19 1:10 PM, Richard Earnshaw (lists) wrote:
>> On 27/01/2019 11:20, Bernd Edlinger wrote:
>>>
>>> $ arm-linux-gnueabihf-gcc -march=armv5te -O3 -S test.c
>>> $ cat test.s
>>> f:
>>> 	@ args = 12, pretend = 0, frame = 0
>>> 	@ frame_needed = 0, uses_anonymous_args = 0
>>> 	@ link register save eliminated.
>>> 	push	{r4, r5}
>>> 	mov	r0, #8
>>> 	ldrd	r4, [sp, #12]
>>
>> So this is wrong; before the compiler can use 'f' it has to copy it to a
>> suitably aligned location; it can't directly reuse the value on the
>> stack as that is not sufficiently aligned for the type.
>>
> 
> Yes, meanwhile I found out that the value would be copied in a new place
> if an address was taken, but there is an issue with
> output_move_double not checking the value's MEM_ALIGN.

I think that's a symptom of an earlier problem: why is gen_movdi being
called with a 32-bit aligned DImode memory object?

R.

> 
>>>
>>> So isn't this wrong code, returning 8 for alignof when it is really 4,
>>> and wouldn't it crash on armv5 and armv6 with SCTLR.U=0 ?
>>
>> Returning 8 is correct; since that is the alignment of the type; but GCC
>> does need to copy underaligned types to suitably aligned memory before
>> it uses them; it must not use the *value* that is passed directly,
>> unless it can prove that doing so is safe (and as you point out, on
>> armv5 it is not).
>>
>> I think technically, this is separate bug from the PCS one that was
>> fixed, so needs a new PR.
>>
> 
> Could you have a look at the patch I sent to fix the wrong code issue:
> https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00248.html
> 
> Is there a chance that this can still go into gcc-9?
> Or do I have to to open a PR for it first?
> 
> 
> Thanks
> Bernd.
> 

  reply	other threads:[~2019-03-01 10:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-27 12:22 Bernd Edlinger
2019-02-28 13:18 ` Richard Earnshaw (lists)
2019-02-28 16:46   ` Bernd Edlinger
2019-03-01 10:03     ` Richard Earnshaw (lists) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-12-17 18:12 Bernd Edlinger
2018-12-17 16:04 Richard Earnshaw (lists)
2019-01-22 14:11 ` Richard Earnshaw (lists)
2019-01-22 14:50   ` Jakub Jelinek
2019-01-22 18:01     ` Richard Earnshaw (lists)

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=fcfc2624-5089-915d-20c6-b9f3f3eb93f2@arm.com \
    --to=richard.earnshaw@arm.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    /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).