From patchwork Fri May 20 19:56:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 624618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rBJbf3Kykz9t6M for ; Sat, 21 May 2016 05:56:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=m9gyEMrr; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=XNgu5yJxDbdNSKqbGT1wh3s91NpUWXojnQiEFkbTJYmnAgSkoD WJi3jYY5z6jTb71uk+cbd+mUdvsVito8IWA1VAEKhP942MyPv+gcjiVdzwzJsEfo Icikpn4ajZwclyS1LzslHAwaXoH2EDOA+eDGeJBzURIX0OT4KFzXsJI+k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=ORGvluMjKcVcjFeRse2jAAgaYfo=; b=m9gyEMrrZdZPa4iZoDTP ivphIUXp0OeleALQMllIO7RUqogE5LolnN9Sx0lY1RFBhajRUzbgnzKKxiMwBaeU nhtLmC7heR36sdGq5WLhuAyDzZFpe55A6mbDf/9wCKBgB02G9sMpUJbHF5rfYQJq 5xcYTyyqOwLNdlh1ACjzxOA= Received: (qmail 99427 invoked by alias); 20 May 2016 19:56:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 99412 invoked by uid 89); 20 May 2016 19:56:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=1, 21, sk:fdumpt, sk:fdump-t, Gives X-HELO: mail-qg0-f43.google.com Received: from mail-qg0-f43.google.com (HELO mail-qg0-f43.google.com) (209.85.192.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 May 2016 19:56:08 +0000 Received: by mail-qg0-f43.google.com with SMTP id f92so65871543qgf.0 for ; Fri, 20 May 2016 12:56:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version; bh=+IEXdU9ztRzXnZzENXBdxtNwn4vDyUzYh/oJp5KETHs=; b=dK+P9K/X8EDg48wA5mb/OfuNii4AYpwSo1VuVRPk95Z+V2GY5CyCI2nD6ylB1eJz+s L7UcPyrZ5ntoZVXKdpsoY1Cy4A5uHXSSpXSyJ+kU4H2Vlpyl7arY8fRDJFSjk8RfuQUh xFB6g66veTL+oWOn9BeQY3xCWLcMGGiM166bovXoiG9Dns5a2y/F/CXIQsr77OBA3pAV L9xMHEo1dX30RP4sS/1g218B9/F3vqACywP+g1fO5dOFsqkn15GWZTLx5jWudHRhIvG0 RwDSu6lF9T9ae3dPI89w2wnWn47Gz2MoZQa1qroC01z55Xzuhr/IEQTUFrZ4DSuWs2OO 7a7g== X-Gm-Message-State: AOPr4FXRpH7BE+95nXOwSXESHLbFY8oBWAneBX3j2zQGR9MwDgvukc6SaAZ3oaSWz9wOfg== X-Received: by 10.140.31.74 with SMTP id e68mr5155078qge.86.1463774166259; Fri, 20 May 2016 12:56:06 -0700 (PDT) Received: from ?IPv6:2601:181:c003:1930:a2a8:cdff:fe3e:b48? ([2601:181:c003:1930:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id y36sm429029qty.37.2016.05.20.12.56.04 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2016 12:56:05 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PTX] toplevel-reorder and no-common flags Message-ID: <67f73f65-32fd-a312-84d9-dfd6ec9c4f0e@acm.org> Date: Fri, 20 May 2016 15:56:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 This patch stops us unconditionally setting the toplevel-reorder flag. It's mostly needed but a couple of testcase rely on it being unset. Those now pass. Also force -fno-common, unless explicitly specified. As the comment says, we fudge common by using .weak, and that's not quite the right thing. So only provide common storage when the user explicitly asks for it. The ssa-store-ccp-2.c testcase is checking some semantics that are only applicable to common storage, so enable that flag. applied to trunk. nathan 2016-05-20 Nathan Sidwell * config/nvptx/nptx.c (nvptx_option_override): Only set flag_toplevel_reorder, if not explicitly specified. Set flag_no_common, unless explicitly specified. testsuite/ * gcc.target/nvptx/uninit-decl.c: Force common storage, add non-common cases. * gcc.dg/tree-ssa/ssa-store-ccp-2.c: Add -fcommon. Index: config/nvptx/nvptx.c =================================================================== --- config/nvptx/nvptx.c (revision 236392) +++ config/nvptx/nvptx.c (working copy) @@ -155,8 +155,19 @@ static void nvptx_option_override (void) { init_machine_status = nvptx_init_machine_status; - /* Gives us a predictable order, which we need especially for variables. */ - flag_toplevel_reorder = 1; + + /* Set toplevel_reorder, unless explicitly disabled. We need + reordering so that we emit necessary assembler decls of + undeclared variables. */ + if (!global_options_set.x_flag_toplevel_reorder) + flag_toplevel_reorder = 1; + + /* Set flag_no_common, unless explicitly disabled. We fake common + using .weak, and that's not entirely accurate, so avoid it + unless forced. */ + if (!global_options_set.x_flag_no_common) + flag_no_common = 1; + /* Assumes that it will see only hard registers. */ flag_var_tracking = 0; Index: testsuite/gcc.target/nvptx/uninit-decl.c =================================================================== --- testsuite/gcc.target/nvptx/uninit-decl.c (revision 236392) +++ testsuite/gcc.target/nvptx/uninit-decl.c (working copy) @@ -1,7 +1,21 @@ /* { dg-do compile } */ -int __attribute__ ((used)) common; -static int __attribute__ ((used)) local; +int __attribute__ ((common)) common; +static int local; +extern int external_decl; +int external_defn; + +int foo () +{ + return common + local + external_decl + external_defn; +} + +void bar (int i) +{ + common = local = external_decl = external_defn = i; +} /* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.weak .global\[^,\n\r\]*common" } } */ /* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.global\[^,\n\r\]*local" } } */ +/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.extern .global\[^,\n\r\]*external_decl" } } */ +/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.visible .global\[^,\n\r\]*external_defn" } } */ Index: testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c =================================================================== --- testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c (revision 236392) +++ testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fcommon" } */ const int conststaticvariable;