From patchwork Mon Sep 25 10:55:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 818171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462874-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jmbpum0C"; dkim-atps=neutral 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 3y11Gb5ZnSz9t3R for ; Mon, 25 Sep 2017 20:56:07 +1000 (AEST) 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=RFP+3DVRkfdCxqlPNQvkL7J83AMGReKN4SEUkPja8XYZkCgUhg U8klE0N2jYstRXQPbAjkUYkoIveKzDM3WUTNz6MacisHL61P+i3+iNQs0AarKM+9 YI9pBXvnxK2xXvjwTNL9HnJ+YoRgqCcd7fKtZBVA7zhI+ekL7p2kop0bY= 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=m4+AwPBW/MlBCvCg/jPnoPPFfZI=; b=jmbpum0Cr0dW38BPJ6u/ D/ea5D9yKAD9dAO8BEKCOjwnTU4+S7zAEwZ0jD6lD54QQqIVIs+9GlKYE4DzJ1lG 7ercBNPkpe4XvsuaKiajj8EWisrtKRQFWZuVUwAsqxnO6mNUat3HizGXevOY0tNB QmYeBnOjb61Fksmht9q0Gt4= Received: (qmail 128154 invoked by alias); 25 Sep 2017 10:56:00 -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 128134 invoked by uid 89); 25 Sep 2017 10:55:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1961, nvidia, informed, atm 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; Mon, 25 Sep 2017 10:55:57 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1dwR3K-0003In-U9 from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Mon, 25 Sep 2017 03:55:54 -0700 Received: from [127.0.0.1] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Mon, 25 Sep 2017 11:55:51 +0100 To: GCC Patches From: Tom de Vries Subject: [nvptx, committed] Add exit after call to noreturn function Message-ID: <3d7059d5-9d8f-09ac-5d08-a3e0da2fb8f5@mentor.com> Date: Mon, 25 Sep 2017 12:55:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi, atm for the nvptx target we're emitting a trap after a noreturn function to indicate the control flow barrier to ptxas: ... call exit, (%out_arg1); trap; // (noreturn) ... However, after reporting a bug to nvidia ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81069#c3 ) we were informed that the trap insn (documented as 'Abort execution and generate an interrupt to the host CPU') in fact is not considered a control flow barrier by ptxas, given that a trap handler may return. The fix that was recommended was to put an exit after the trap. This patch implements that. Committed. Thanks, - Tom [nvptx] Add exit after call to noreturn function 2017-09-25 Tom de Vries PR target/80035 PR target/81069 * config/nvptx/nvptx.c (nvptx_output_call_insn): Add exit after call to noreturn function. --- gcc/config/nvptx/nvptx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 6cf9a66..634f660 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -2304,11 +2304,14 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) fprintf (asm_out_file, ";\n"); if (find_reg_note (insn, REG_NORETURN, NULL)) - /* No return functions confuse the PTX JIT, as it doesn't realize - the flow control barrier they imply. It can seg fault if it - encounters what looks like an unexitable loop. Emit a trailing - trap, which it does grok. */ - fprintf (asm_out_file, "\t\ttrap; // (noreturn)\n"); + { + /* No return functions confuse the PTX JIT, as it doesn't realize + the flow control barrier they imply. It can seg fault if it + encounters what looks like an unexitable loop. Emit a trailing + trap and exit, which it does grok. */ + fprintf (asm_out_file, "\t\ttrap; // (noreturn)\n"); + fprintf (asm_out_file, "\t\texit; // (noreturn)\n"); + } if (result) {