Re: [PATCH 3/3] Implement the "persistent" attribute

2020-11-21 Thread Jeff Law via Gcc-patches



On 11/15/20 3:06 PM, Jozef Lawrynowicz wrote:
> The "persistent" attribute is used for variables that are initialized
> by the program loader, but are not initialized by the runtime startup
> code. "persistent" variables are placed in a non-volatile area of
> memory, which allows their value to "persist" between processor resets.
>
> Successfully regtested for arm-none-eabi.
>
> Ok for trunk?
>
> 0003-Implement-the-persistent-attribute.patch
>
> From c67b1bb6f46a69916c7de74617f4301b95c894d8 Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz 
> Date: Sun, 15 Nov 2020 21:44:10 +
> Subject: [PATCH 3/3] Implement the "persistent" attribute
>
> The "persistent" attribute is used for variables that are initialized
> by the program loader, but are not initialized by the runtime startup
> code. "persistent" variables are placed in a non-volatile area of
> memory, which allows their value to "persist" between processor resets.
>
> gcc/c-family/ChangeLog:
>
>   * c-attribs.c (handle_special_var_sec_attribute): New.
>   (handle_noinit_attribute): Remove.
>   (attr_noinit_exclusions): Rename to...
>   (attr_section_exclusions): ...this, and add "persistent" attribute
>   exclusion.
>   (c_common_attribute_table): Add "persistent" attribute.
>
> gcc/ChangeLog:
>
>   * doc/extend.texi: Document the "persistent" variable attribute.
>   * tree.h (DECL_PERSISTENT_P): Define.
>   * varasm.c (bss_initializer_p): Return false for a
>   DECL_PERSISTENT_P decl initialized to zero.
>   (default_section_type_flags): Handle the ".persistent" section.
>   (default_elf_select_section): Likewise.
>   (default_unique_section): Likewise.
>
> gcc/testsuite/ChangeLog:
>
>   * gcc.c-torture/execute/noinit-attribute.c: Moved to...
>   * c-c++-common/torture/attr-noinit-main.inc: ...here.
>   * lib/target-supports.exp (check_effective_target_persistent): New.
>   * c-c++-common/torture/attr-noinit-1.c: New test.
>   * c-c++-common/torture/attr-noinit-2.c: New test.
>   * c-c++-common/torture/attr-noinit-3.c: New test.
>   * c-c++-common/torture/attr-noinit-invalid.c: New test.
>   * c-c++-common/torture/attr-persistent-1.c: New test.
>   * c-c++-common/torture/attr-persistent-2.c: New test.
>   * c-c++-common/torture/attr-persistent-3.c: New test.
>   * c-c++-common/torture/attr-persistent-invalid.c: New test.
>   * c-c++-common/torture/attr-persistent-main.inc: New test.
I think you need to document the new effective target check in
sourcebuild.texi.  With that change this is OK

jeff



[PATCH 3/3] Implement the "persistent" attribute

2020-11-15 Thread Jozef Lawrynowicz
The "persistent" attribute is used for variables that are initialized
by the program loader, but are not initialized by the runtime startup
code. "persistent" variables are placed in a non-volatile area of
memory, which allows their value to "persist" between processor resets.

Successfully regtested for arm-none-eabi.

Ok for trunk?
>From c67b1bb6f46a69916c7de74617f4301b95c894d8 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz 
Date: Sun, 15 Nov 2020 21:44:10 +0000
Subject: [PATCH 3/3] Implement the "persistent" attribute

The "persistent" attribute is used for variables that are initialized
by the program loader, but are not initialized by the runtime startup
code. "persistent" variables are placed in a non-volatile area of
memory, which allows their value to "persist" between processor resets.

gcc/c-family/ChangeLog:

* c-attribs.c (handle_special_var_sec_attribute): New.
(handle_noinit_attribute): Remove.
(attr_noinit_exclusions): Rename to...
(attr_section_exclusions): ...this, and add "persistent" attribute
exclusion.
(c_common_attribute_table): Add "persistent" attribute.

gcc/ChangeLog:

* doc/extend.texi: Document the "persistent" variable attribute.
* tree.h (DECL_PERSISTENT_P): Define.
* varasm.c (bss_initializer_p): Return false for a
DECL_PERSISTENT_P decl initialized to zero.
(default_section_type_flags): Handle the ".persistent" section.
(default_elf_select_section): Likewise.
(default_unique_section): Likewise.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/noinit-attribute.c: Moved to...
* c-c++-common/torture/attr-noinit-main.inc: ...here.
* lib/target-supports.exp (check_effective_target_persistent): New.
* c-c++-common/torture/attr-noinit-1.c: New test.
* c-c++-common/torture/attr-noinit-2.c: New test.
* c-c++-common/torture/attr-noinit-3.c: New test.
* c-c++-common/torture/attr-noinit-invalid.c: New test.
* c-c++-common/torture/attr-persistent-1.c: New test.
* c-c++-common/torture/attr-persistent-2.c: New test.
* c-c++-common/torture/attr-persistent-3.c: New test.
* c-c++-common/torture/attr-persistent-invalid.c: New test.
* c-c++-common/torture/attr-persistent-main.inc: New test.
---
 gcc/c-family/c-attribs.c  | 141 --
 gcc/doc/extend.texi   |  20 ++-
 .../c-c++-common/torture/attr-noinit-1.c  |   7 +
 .../c-c++-common/torture/attr-noinit-2.c  |   8 +
 .../c-c++-common/torture/attr-noinit-3.c  |  11 ++
 .../torture/attr-noinit-invalid.c |  12 ++
 .../torture/attr-noinit-main.inc} |  37 ++---
 .../c-c++-common/torture/attr-persistent-1.c  |   8 +
 .../c-c++-common/torture/attr-persistent-2.c  |   8 +
 .../c-c++-common/torture/attr-persistent-3.c  |  10 ++
 .../torture/attr-persistent-invalid.c |  11 ++
 .../torture/attr-persistent-main.inc  |  58 +++
 gcc/testsuite/lib/target-supports.exp |  13 ++
 gcc/tree.h|   7 +
 gcc/varasm.c  |  19 ++-
 15 files changed, 301 insertions(+), 69 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-noinit-1.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-noinit-2.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-noinit-3.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-noinit-invalid.c
 rename gcc/testsuite/{gcc.c-torture/execute/noinit-attribute.c => 
c-c++-common/torture/attr-noinit-main.inc} (55%)
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-persistent-1.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-persistent-2.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-persistent-3.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-persistent-invalid.c
 create mode 100644 gcc/testsuite/c-c++-common/torture/attr-persistent-main.inc

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index f1680820ecd..6b26f43c298 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -94,10 +94,10 @@ static tree handle_constructor_attribute (tree *, tree, 
tree, int, bool *);
 static tree handle_destructor_attribute (tree *, tree, tree, int, bool *);
 static tree handle_mode_attribute (tree *, tree, tree, int, bool *);
 static tree handle_section_attribute (tree *, tree, tree, int, bool *);
+static tree handle_special_var_sec_attribute (tree *, tree, tree, int, bool *);
 static tree handle_aligned_attribute (tree *, tree, tree, int, bool *);
 static tree handle_warn_if_not_aligned_attribute (tree *, tree, tree,
  int, bool *);
-static tree handle_noinit_attribute (t