From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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, 01 Jun 2016 13:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7C53D99D801DDFB595813270" X-SW-Source: 2016-06/txt/msg00042.txt.bz2 This is a multi-part message in MIME format. --------------7C53D99D801DDFB595813270 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 372 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 --------------7C53D99D801DDFB595813270 Content-Type: text/x-patch; name="ptx-weak-decl.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ptx-weak-decl.patch" Content-length: 1679 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; +} + --------------7C53D99D801DDFB595813270--