aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-11 18:35:13 +0100
committerJakub Jelinek <jakub@redhat.com>2020-03-11 18:35:13 +0100
commitd42ff1d3b62521829d90e5b972baba2a0339e2bf (patch)
treeb8ba19dc256c9ec4cf86ad40db785ab88557fa6f /gcc
parent5fea87cc7902c7c03c0d3c8cf7784cd99db8315d (diff)
downloadgcc-d42ff1d3b62521829d90e5b972baba2a0339e2bf.zip
gcc-d42ff1d3b62521829d90e5b972baba2a0339e2bf.tar.gz
gcc-d42ff1d3b62521829d90e5b972baba2a0339e2bf.tar.bz2
pdp11: Fix handling of common (local and global) vars [PR94134]
As mentioned in the PR, the generic code decides to put the a variable into lcomm_section, which is a NOSWITCH section and thus the generic code doesn't switch into a particular section before using ASM_OUTPUT{_ALIGNED{,_DECL}_}_LOCAL, on many targets that results just in .lcomm (or for non-local .comm) directives which don't need a switch to some section, other targets put switch_to_section (bss_section) at the start of that macro. pdp11 doesn't do that (and doesn't have bss_section), and so emits the lcomm/comm variables in whatever section is current (it has only .text/.data and for DEC assembler rodata). The following patch fixes that by putting it always into data section, and additionally avoids emitting an empty line in the assembly for the lcomm vars. 2020-03-11 Jakub Jelinek <jakub@redhat.com> PR target/94134 * config/pdp11/pdp11.c (pdp11_asm_output_var): Call switch_to_section at the start to switch to data section. Don't print extra newline if .globl directive has not been emitted. * gcc.c-torture/execute/pr94134.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/pdp11/pdp11.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr94134.c14
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 73339dc..818cf19 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/94134
+ * config/pdp11/pdp11.c (pdp11_asm_output_var): Call switch_to_section
+ at the start to switch to data section. Don't print extra newline if
+ .globl directive has not been emitted.
+
2020-03-11 Richard Biener <rguenther@suse.de>
* match.pd ((T *)(ptr - ptr-cst) -> &MEM[ptr + -ptr-cst]):
diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c
index c8612ad..25590be 100644
--- a/gcc/config/pdp11/pdp11.c
+++ b/gcc/config/pdp11/pdp11.c
@@ -743,6 +743,7 @@ void
pdp11_asm_output_var (FILE *file, const char *name, int size,
int align, bool global)
{
+ switch_to_section (data_section);
if (align > 8)
fprintf (file, "\t.even\n");
if (TARGET_DEC_ASM)
@@ -763,8 +764,8 @@ pdp11_asm_output_var (FILE *file, const char *name, int size,
{
fprintf (file, ".globl ");
assemble_name (file, name);
+ fprintf (file, "\n");
}
- fprintf (file, "\n");
assemble_name (file, name);
fputs (":", file);
ASM_OUTPUT_SKIP (file, size);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e2442fb..ba4cd14 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/94134
+ * gcc.c-torture/execute/pr94134.c: New test.
+
2020-03-11 Kito Cheng <kito.cheng@sifive.com>
* gcc.target/riscv/interrupt-2.c: Update testcase and expected output.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr94134.c b/gcc/testsuite/gcc.c-torture/execute/pr94134.c
new file mode 100644
index 0000000..b1b44c3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr94134.c
@@ -0,0 +1,14 @@
+/* PR target/94134 */
+
+static volatile int a = 0;
+static volatile int b = 1;
+
+int
+main ()
+{
+ a++;
+ b++;
+ if (a != 1 || b != 2)
+ __builtin_abort ();
+ return 0;
+}