* [PATCH 1/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
@ 2017-05-17 15:46 Jozef Lawrynowicz
0 siblings, 0 replies; only message in thread
From: Jozef Lawrynowicz @ 2017-05-17 15:46 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
Change back end and add tests.
Patch is attached.
Note: Patch will not apply if
https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01030.html has been
committed. "$DEFAULT_CFLAGS" in msp430.exp would need to be changed to
"$MSP430_DEFAULT_CFLAGS".
If the patch is acceptable, I would appreciate if someone could commit
it for me as I do not have write access.
2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Set section to
.persistent if persistent attribute is set.
gcc/testsuite
PR target/78818
* gcc.target/msp430/msp430.exp: Search for tests in subfolders as well as
main directory.
* gcc.target/msp430/pr78818/pr78818-real.c: New template for tests.
* gcc.target/msp430/pr78818/pr78818-auto.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-region.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-sec.c: Likewise.
[-- Attachment #2: 0001-MSP430-Fix-persistent-attribute-not-placing-data-int.patch --]
[-- Type: application/octet-stream, Size: 4877 bytes --]
From 61e00b30a431238cf1ffe5497b6f170c73e8d98a Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Fri, 12 May 2017 13:04:59 +0000
Subject: [PATCH 1/2] MSP430: Fix persistent attribute not placing data into
the .persistent section
2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Set section to
.persistent if persistent attribute is set.
gcc/testsuite
PR target/78818
* gcc.target/msp430/msp430.exp: Search for tests in subfolders as well as
main directory.
* gcc.target/msp430/pr78818/pr78818-real.c: New template for tests.
* gcc.target/msp430/pr78818/pr78818-auto.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-region.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-sec.c: Likewise.
---
gcc/config/msp430/msp430.c | 7 +++++++
gcc/testsuite/gcc.target/msp430/msp430.exp | 4 ++--
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c | 5 +++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c | 7 +++++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c | 8 ++++++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c | 9 +++++++++
6 files changed, 38 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index 6f63116..c70121e 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -1975,6 +1975,13 @@ msp430_data_attr (tree * node,
if (DECL_SECTION_NAME (* node))
message = "%qE attribute cannot be applied to variables with specific sections";
+ /* It's not clear if there is anything that can be set here to prevent the
+ * front end placing the variable before the back end can handle it, in a
+ * similar way to how DECL_COMMON is used below.
+ * So just place the variable in the .persistent section now. */
+ if (TREE_NAME_EQ (name, ATTR_PERSIST))
+ set_decl_section_name (* node, ".persistent");
+
/* If this var is thought to be common, then change this. Common variables
are assigned to sections before the backend has a chance to process them. */
if (DECL_COMMON (* node))
diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp
index deb2e25..3b5513c 100644
--- a/gcc/testsuite/gcc.target/msp430/msp430.exp
+++ b/gcc/testsuite/gcc.target/msp430/msp430.exp
@@ -34,8 +34,8 @@ if ![info exists DEFAULT_CFLAGS] then {
dg-init
# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
- "" $DEFAULT_CFLAGS
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/{*,*/*}.\[cCS\]]] \
+ "" $DEFAULT_CFLAGS
# All done.
dg-finish
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
new file mode 100644
index 0000000..1fb0b28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+/* { dg-final { scan-assembler-not "\\.comm" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
new file mode 100644
index 0000000..5da6a82
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+/* { dg-options "-mdata-region=either" } */
+
+/* { dg-final { scan-assembler-not "\\.either" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
new file mode 100644
index 0000000..2d40ea7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+/* { dg-options "-fdata-sections" } */
+
+/* { dg-final { scan-assembler-not "\\.data" } } */
+/* { dg-final { scan-assembler-not "\\.bss" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
new file mode 100644
index 0000000..504ed4a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
@@ -0,0 +1,9 @@
+__attribute__((persistent)) int persistent_1 = 1;
+__attribute__((persistent)) int persistent_2 = 0;
+static __attribute__((persistent)) int persistent_3 = 1;
+static __attribute__((persistent)) int persistent_4 = 0;
+
+int main (void)
+{
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-17 15:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 15:46 [PATCH 1/2] [MSP430] Fix issues handling .persistent attribute (PR 78818) Jozef Lawrynowicz
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).