This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] [RFC] PR target/52813 and target/11807
- From: Dimitar Dimitrov <dimitar at dinux dot eu>
- To: Christophe Lyon <christophe dot lyon at linaro dot org>
- Cc: Thomas Preudhomme <thomas dot preudhomme at linaro dot org>, gcc Patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <richard dot sandiford at arm dot com>, Thomas Preud'homme <thomas dot preudhomme at arm dot com>
- Date: Wed, 12 Dec 2018 18:26:10 +0200
- Subject: Re: [PATCH] [RFC] PR target/52813 and target/11807
- References: <email@example.com> <CAKnkMGvqbnVU-Gap5X55mbY8f8cG1ZiVMitczgYVyPvK6EEvRA@mail.gmail.com> <CAKdteOaqBa4Cf8kTOEEWMeJgRxMaq45sXGTrjdq=4G7SWBw8Fg@mail.gmail.com>
On Wed, 12 Dec 2018 at 14:19:27 EET Christophe Lyon wrote:
> On Wed, 12 Dec 2018 at 12:21, Thomas Preudhomme
> <firstname.lastname@example.org> wrote:
> > So my understanding is that the original code (CMSIS library) used to
> > clobber sp because the asm statement was actually changing the sp.
> > That in turn led GCC to try to save and restore sp which is not what
> > CMSIS was expecting to happen. Changing sp without clobber as done now
> > is probably the right solution and r242693 can be reverted. That will
> > remove the failing test.
> OK, I read PR52813 too, but I'm not sure to fully understand the new status.
> My understanding is that since this patch was committed, if an asm
> statement clobbers sp, it is now allowed to actually declare it as clobber
> (this patch generates an error in such a case).
> So the user is now expected to lie to the compiler when writing to
> this kind of register (sp, pic register), by not declaring it as "clobber"?
Disclosure: I'm a GCC newbie.
I expect that if I mark a HW register as "clobber", compiler would save its
contents before executing the asm statement, and after that it would restore
its contents. This is the GCC behaviour for all but the SP and PIC registers.
That is why I believe that PR52813 is a valid bug.
I'm not sure how GCC could recover if SP is clobbered. If SP is clobbered in
such a way that GCC will not notice (e.g. thread switching), then why should
GCC know about it in the first place?