From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18364 invoked by alias); 19 Dec 2017 23:25:29 -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 18348 invoked by uid 89); 19 Dec 2017 23:25:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Dec 2017 23:25:26 +0000 Received: from svr-orw-mbx-04.mgc.mentorg.com ([147.34.90.204]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1eRRGF-0002Gp-0b from Cesar_Philippidis@mentor.com for gcc-patches@gcc.gnu.org; Tue, 19 Dec 2017 15:25:23 -0800 Received: from [127.0.0.1] (147.34.91.1) by SVR-ORW-MBX-04.mgc.mentorg.com (147.34.90.204) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Tue, 19 Dec 2017 15:25:20 -0800 From: Cesar Philippidis Subject: [PATCH,PTX] Add support for CUDA 9 To: Tom de Vries , "gcc-patches@gcc.gnu.org" Message-ID: <002bf03f-baad-5809-6e9a-2fdffa0c1e2c@codesourcery.com> Date: Tue, 19 Dec 2017 23:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3E150475B3E2EBF6FE145A22" X-ClientProxiedBy: SVR-ORW-MBX-05.mgc.mentorg.com (147.34.90.205) To SVR-ORW-MBX-04.mgc.mentorg.com (147.34.90.204) X-SW-Source: 2017-12/txt/msg01318.txt.bz2 --------------3E150475B3E2EBF6FE145A22 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 697 In CUDA 9, Nvidia removed support for treating the labels of functions as generic address spaces as part of their PTX 6.0 changes. More specifically, : Support for taking address of labels, using labels in initializers which was unimplemented has been removed from the spec. Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no longer support that legacy functionality. Consequently, this prevented newlib from building. This patch fixes that problem by not using a generic address space when initializing variables using a label address. Is this OK for trunk? Thanks, Cesar --------------3E150475B3E2EBF6FE145A22 Content-Type: text/x-patch; name="og7-ptx-cuda9.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="og7-ptx-cuda9.diff" Content-length: 1358 2017-12-19 Cesar Philippidis gcc/ * config/nvptx/nvptx.c (output_init_frag): Don't use generic address spaces for function labels. gcc/testsuite/ * gcc.target/nvptx/indirect_call.c: New test. diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index dfb27ef..a7b4c09 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -1894,9 +1894,15 @@ output_init_frag (rtx sym) if (sym) { - fprintf (asm_out_file, "generic("); + bool function = SYMBOL_REF_DECL (sym) + && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL); + if (!function) + fprintf (asm_out_file, "generic("); output_address (VOIDmode, sym); - fprintf (asm_out_file, val ? ") + " : ")"); + if (!function) + fprintf (asm_out_file, val ? ") + " : ")"); + else if (val) + fprintf (asm_out_file, " + "); } if (!sym || val) diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c new file mode 100644 index 0000000..39992a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -msoft-stack" } */ +/* { dg-do run } */ + +int +f1 (int a) +{ + return a + 1; +} + +int (*f2)(int) = f1; + +int +main () +{ + if (f2 (100) != 101) + __builtin_abort(); + + return 0; +} --------------3E150475B3E2EBF6FE145A22--