From patchwork Wed Jun 1 13:44:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 628676 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 3rKWmy3TwVz9t3h for ; Wed, 1 Jun 2016 23:44:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mhonBiIf; 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=bSBP6BewtPhuF9oMwyStxTns6m8U92rlyJ3OdQxRG4r1rv6mxN 9SFJ3QmsOFqRBGqfHJDaef0VVD+Dq1uWK6cfmzlG/K7sQsYZh7u0eH5lzduAielM L+k2r95a5TMZOHQvkrz6L8DTa/Pe1rlaeZs5G+fw4S81LUDp197EVXGys= 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=ugy0QkLbvuBEDWXxBl8x7bKzBjA=; b=mhonBiIfxF1MunDLZNqZ neIsgTU6uLbDTRB9N92Q8+C+/yIRyh2Gbhy/aR9i0L7oy2YiCPSE3u6IHSJZ/nKV EC5uU/VFV7Km5NyON+q2Wzk4urQCVJXdhJUwF4pLNlCyKbAdXtMHCEIPQnxxnV7U 4HfGaDy16sGqFhiVG/i/RMU= Received: (qmail 111373 invoked by alias); 1 Jun 2016 13:44:26 -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 111359 invoked by uid 89); 1 Jun 2016 13:44:25 -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=Hx-languages-length:2016, 95 X-HELO: mail-qk0-f172.google.com Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 01 Jun 2016 13:44:15 +0000 Received: by mail-qk0-f172.google.com with SMTP id n63so14519244qkf.0 for ; Wed, 01 Jun 2016 06:44:14 -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=+MyNaFjchRTMehZ44O3tmXpZ+XkkxEfDfUasctCVo/Y=; b=Pl4OMDDWGN0VjJ1UM13u+yYkdXzDYFoO+up1dqTgzlwYHLHiLLobuldmS8olaOrnPH 271GdssQkw63+NGnzzngQ+nJqavpWYPeBKA/RpcfMbPZqdMUJmSXqmzJZAEqlpLvLES/ BZNdBSEZZ/c0i+qiISoedAchYLUnDmfZg9nk9V7J13+U3gXyjTPki/C2X4AgcSKqtDnr wyk09BrZAnQBKWrs9tnauNAi4Q5gqrlgGg4zVNSYUzY72Ujg2I3XOpUSXXFM+tlBLAtf PsrxuLxtSoZxvXIjW0Ekv4vHU+HDvL0XsjZD7ZWKH3tyH3XmMUC+7AQPkgL/fDJpGNPm pvWQ== X-Gm-Message-State: ALyK8tKdHSYN4tMEBOC4ub0ViRLsgR5Bn5ERRnHkfNO/acYh0YN0d1nIjGtZubzBKxItpw== X-Received: by 10.200.37.65 with SMTP id 1mr3513111qtn.29.1464788652893; Wed, 01 Jun 2016 06:44:12 -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 x134sm12404241qkx.12.2016.06.01.06.44.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Jun 2016 06:44:12 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PTX] weak references Message-ID: Date: Wed, 1 Jun 2016 09:44:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 This patch emits an error if you try and weakly reference a declaration. PTX doesn't support that. I tried overriding ASM_OUTPUT_WEAREF, but that didn't seem to work. So this is added to the assemble_undefined_decl hook. that does mean it requires -ftoplevel-reorder to function, but that flags's on for PTX unless explicitly disabled. Committed to trunk nathan 2016-06-01 Nathan Sidwell * config/nvptx/nvptx.c (nvptx_assemble_undefined_decl): Reject undefined weak. testsuite/ * c-c++-common/torture/pr57945.c: Add expected PTX error. * gcc.target/nvptx/weak.c: New. Index: config/nvptx/nvptx.c =================================================================== --- config/nvptx/nvptx.c (revision 236919) +++ config/nvptx/nvptx.c (working copy) @@ -1777,6 +1777,12 @@ nvptx_assemble_undefined_decl (FILE *fil if (DECL_IN_CONSTANT_POOL (decl)) return; + /* We support weak defintions, and hence have the right + ASM_WEAKEN_DECL definition. Diagnose the problem here. */ + if (DECL_WEAK (decl)) + error_at (DECL_SOURCE_LOCATION (decl), + "PTX does not support weak declarations" + " (only weak definitions)"); write_var_marker (file, false, TREE_PUBLIC (decl), name); fprintf (file, "\t.extern "); Index: testsuite/c-c++-common/torture/pr57945.c =================================================================== --- testsuite/c-c++-common/torture/pr57945.c (revision 236919) +++ testsuite/c-c++-common/torture/pr57945.c (working copy) @@ -9,3 +9,5 @@ foo (void) { return &i ? i : 0; } + +/* { dg-error "PTX does not support weak declarations" "" { target nvptx-*-* } 5 } */ Index: testsuite/gcc.target/nvptx/weak.c =================================================================== --- testsuite/gcc.target/nvptx/weak.c (nonexistent) +++ testsuite/gcc.target/nvptx/weak.c (working copy) @@ -0,0 +1,9 @@ + +extern int __attribute__((weak)) decl; /* { dg-error "weak declarations" } */ +int __attribute__((weak)) defn; + +int Foo () +{ + return decl + defn; +} +