From patchwork Wed Mar 11 17:12:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1253076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=cLjik7ir; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cz6P2lDyz9sPF for ; Thu, 12 Mar 2020 04:12:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27D65394440D; Wed, 11 Mar 2020 17:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27D65394440D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1583946741; bh=OFY8rPqXHmSH39odFHXx+4FC/m9ty/GfL0krbPCiFas=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=cLjik7ir2+uOFZPkXdPy0mHMqbDEvCVvKmRvBULjIUPljqlqBNionzQhLs7zK5h/c w0V6sMLTjx/lF/cSpWFMr7yTne33NBCfXxktfI99tKq+7NVFS4/Z+2ezRizIt+zhlJ P37AJovU9WW7YUsNaUI83zcBGT1iJkddrdupltqs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 84E8E394201D for ; Wed, 11 Mar 2020 17:12:19 +0000 (GMT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-Qo05nBEENCab05kGSNh05g-1; Wed, 11 Mar 2020 13:12:17 -0400 X-MC-Unique: Qo05nBEENCab05kGSNh05g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1778F18C43D0; Wed, 11 Mar 2020 17:12:16 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C5275C13D; Wed, 11 Mar 2020 17:12:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 02BHCDpv026566; Wed, 11 Mar 2020 18:12:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 02BHCAS8026564; Wed, 11 Mar 2020 18:12:10 +0100 Date: Wed, 11 Mar 2020 18:12:10 +0100 To: Paul Koning Subject: [PATCH] pdp11: Fix handling of common (local and global) vars [PR94134] Message-ID: <20200311171210.GF2156@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! 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. Tested on the testcase, I'm afraid I have no other way to test this target. Ok for trunk? 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. Jakub --- gcc/config/pdp11/pdp11.c.jj 2020-01-12 11:54:36.382413876 +0100 +++ gcc/config/pdp11/pdp11.c 2020-03-11 15:44:43.373970000 +0100 @@ -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 { fprintf (file, ".globl "); assemble_name (file, name); + fprintf (file, "\n"); } - fprintf (file, "\n"); assemble_name (file, name); fputs (":", file); ASM_OUTPUT_SKIP (file, size); --- gcc/testsuite/gcc.c-torture/execute/pr94134.c.jj 2020-03-11 15:46:09.540710642 +0100 +++ gcc/testsuite/gcc.c-torture/execute/pr94134.c 2020-03-11 15:40:18.538840663 +0100 @@ -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; +}