From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id C468639878ED; Thu, 17 Sep 2020 14:24:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C468639878ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600352686; bh=DVznusOeO3xkR/ryw7juBkSN5isrvMqAkURBBIVcV/4=; h=From:To:Subject:Date:From; b=LWWWkhHhlNZ2Q9jd6K6RrNgogcN/zEm+AEJDuRiMuFRcadsru6t5llpkzyRgYLQqN YVTyaELvsf1fMq0LXBajvpX7zGFegT4vwqvPpHoXl3H8S5G6Q1N+Ez3qgwcZNbC8SD TB3C70qxZx363kIwAGSG0RHMEiAGB3dbYdUgP0FE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r8-10462] pdp11: Fix handling of common (local and global) vars [PR94134] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-8 X-Git-Oldrev: 5f6826f724348c4e1317c15ea4cea01d5604fc39 X-Git-Newrev: 4910b2e4cfe25c95fef18cf54125b788c190cfb2 Message-Id: <20200917142446.C468639878ED@sourceware.org> Date: Thu, 17 Sep 2020 14:24:46 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 14:24:46 -0000 https://gcc.gnu.org/g:4910b2e4cfe25c95fef18cf54125b788c190cfb2 commit r8-10462-g4910b2e4cfe25c95fef18cf54125b788c190cfb2 Author: Jakub Jelinek Date: Wed Mar 11 18:35:13 2020 +0100 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 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. (cherry picked from commit f1125cf88ac0c97d819e4f81d556fbcd1161270e) Diff: --- gcc/config/pdp11/pdp11.c | 3 ++- gcc/testsuite/gcc.c-torture/execute/pr94134.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 38c55fbb3df..3c4351477e9 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -720,14 +720,15 @@ 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, "\n\t.even\n"); if (global) { fprintf (file, ".globl "); assemble_name (file, name); + fprintf (file, "\n"); } - fprintf (file, "\n"); assemble_name (file, name); fprintf (file, ": .=.+ %#ho\n", (unsigned short)size); } 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 00000000000..b1b44c3b184 --- /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; +}