This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] doc: discourage const/volatile on register variables
- From: Jeff Law <law at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>, Alexander Monakov <amonakov at ispras dot ru>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 2 Aug 2018 10:08:56 -0600
- Subject: Re: [PATCH] doc: discourage const/volatile on register variables
- References: <alpine.LNX.email@example.com> <CAFiYyc2EbRAMo21uL52fAr6ZHZnb4Va8pPkxH+N8CHKyg-bJ-Q@mail.gmail.com>
On 07/26/2018 05:18 AM, Richard Biener wrote:
> On Thu, Jul 26, 2018 at 12:29 PM Alexander Monakov <firstname.lastname@example.org> wrote:
>> when using explicit register variables ('register int foo asm("%ebp");'),
>> using const/volatile type qualifiers on the declaration does not result in
>> the logically expected effect.
>> The main issue is that gcc-8 got "better" at propagating initializers of
>> 'register const' variables to their uses in asm operands, losing the
>> association with the register and thus causing the operand to
>> unexpectedly appear in some other register. This caused build issues for
>> the Linux kernel and was reported a couple of times in the GCC Bugzilla.
>> This patch adds a few lines to the documentation to say that qualifiers
>> won't work as expected. OK for trunk?
> Looks ok to me. Maybe we should change FEs to ignore those
> qualifiers on explicit register variables and emit a warning like
> warning: const/volatile qualifier ignored on X
It'd certainly help catch these kinds of issues earlier rather than
seeing the assembler barf when the constant gets propagated or some