public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: Christophe Lyon <christophe.lyon@linaro.org>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
	Richard Earnshaw <Richard.Earnshaw@arm.com>,
	nick clifton <nickc@redhat.com>
Subject: Re: [PATCH] Add generic support for "noinit" attribute
Date: Fri, 05 Jul 2019 11:09:00 -0000	[thread overview]
Message-ID: <20190705115715.1a4806a3@jozef-kubuntu> (raw)
In-Reply-To: <CAKdteOYQmg0F7cK50=wHhEbaOVrEK0dtE=xqqfJ_EvdZ7=A8Eg@mail.gmail.com>

On Fri, 5 Jul 2019 11:26:20 +0200
Christophe Lyon <christophe.lyon@linaro.org> wrote:

> On Thu, 4 Jul 2019 at 23:46, Jozef Lawrynowicz <jozef.l@mittosystems.com> wrote:
> >
> > Also, the gcc.target/arm/noinit-attribute.c test works with msp430.
> > Why not create a effective-target keyword which checks for noinit support, so
> > the test can be gated on that condition and put in a generic part of the
> > testsuite?  
> 
> That was my intention, and I was waiting for feedback on this. In this
> case, I suppose the effective-target check would test a hardcoded list
> of targets, like many other effective-targets?
> (eg check_weak_available)

Were there previous discussions on whether the noinit attribute should be
explicitly enabled for certain targets? e.g. so it will error if you try to use
it on x86_64.
If it will just be enabled by default for all targets then a hardcoded
list for check-effective target sounds ok. Otherwise if it does cause an error
when used on an unsupported target you could do a check that the
attribute compiles successfully instead.

> 
> > After doing some further testing, I noticed the attribute does not work on
> > static variables. The attribute handling code allows the attribute to be set on
> > a static variable, but then that variable does not get placed in the .noinit
> > section.
> >
> > What are your thoughts on this?
> >
> > Does it even makes sense for a static local variable to be declared as "noinit"?
> > One should want a static local variable to be initialized, as having it not
> > initialized and hold a random value could cause problems.
> > Perhaps a user could think of some use for this, but I can't.
> >  
> I added:
> static int __attribute__((noinit)) var_noinit2;
> in global scope, and
> static int __attribute__((noinit)) var_noinit3;
> in main(), and the generate code contains:
>         .section        .noinit,"aw"
>         .align  2
>         .set    .LANCHOR2,. + 0
>         .type   var_noinit2, %object
>         .size   var_noinit2, 4
> var_noinit2:
>         .space  4
>         .type   var_noinit3.4160, %object
>         .size   var_noinit3.4160, 4
> var_noinit3.4160:
>         .space  4
>         .type   var_noinit, %object
>         .size   var_noinit, 4
> var_noinit:
>         .space  4
> 
> So, all three of them are in the .noinit section, but only var_noinit has
>         .global var_noinit
> 
> So it seems to work?

Hmm yes there seems to be an issue with trunks handling of noinit for msp430.
Even before your patch the static noinit variables are marked as
common symbols with ".comm" and are not placed in .noinit.

These static noinit variables work with my downstream msp430-gcc (which doesn't
yet have parity with upstream), so this is just something I'll fix separately,
and doesn't represent any issues with your patch.

Jozef

  reply	other threads:[~2019-07-05 10:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 15:34 Christophe Lyon
2019-07-04 15:43 ` Jozef Lawrynowicz
2019-07-04 21:46 ` Jozef Lawrynowicz
2019-07-05 10:32   ` Christophe Lyon
2019-07-05 11:09     ` Jozef Lawrynowicz [this message]
2019-07-05 11:50       ` Christophe Lyon
2019-07-06 20:35 ` Martin Sebor
2019-07-08 11:27   ` Christophe Lyon
2019-07-08 22:10     ` Martin Sebor
2019-07-16  9:07       ` Christophe Lyon
2019-07-16 10:11     ` Richard Sandiford
2019-07-30 13:38       ` Christophe Lyon
2019-08-12 17:07         ` Jozef Lawrynowicz
2019-08-13 18:21         ` Christophe Lyon
2019-08-14 13:05         ` Richard Sandiford
2019-08-14 13:36           ` Christophe Lyon
2019-08-14 16:11             ` Tamar Christina
2019-08-14 17:20               ` Christophe Lyon
2019-08-14 18:04                 ` Christophe Lyon

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=20190705115715.1a4806a3@jozef-kubuntu \
    --to=jozef.l@mittosystems.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nickc@redhat.com \
    /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).