From patchwork Fri May 24 11:12:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1104812 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-501626-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cdpPX+/e"; 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 459Nxv4JSXz9s6w for ; Fri, 24 May 2019 21:12:35 +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=Y4beEKylM6+hrsjEv6jGdDXmnEstFTMp8DWEbRwiqDY3AJNsaW 8i8MbmTO8XplXQgPdE99GEGHxDec4W7nD+Qf53/vcDDOVwSR4ip0MpL/7/2M844y fGS4jDPhkyioMeyQveW5nsMKtpy6EbeBGr2Zd7Ol5SMK2qdi99+PbngCM= 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=wq8PClrrLlEVyY9YSQRC/J8N3Ac=; b=cdpPX+/ei2exWO5YgNFA jnSkBU+9V30ThzRE6buA5qlo/hiSjxGmwM5pzdlFqAkeQGCbanFvYbBQpY8YcuPn 00EvTMv7AU8DFMP31e4nVlg5TXPQpEJeiAo+uaWkMvQQPzA06JLexeQTh8JxYFHe agFP5fXLZ+ZPZ80N1amD5C0= Received: (qmail 75805 invoked by alias); 24 May 2019 11:12:28 -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 75796 invoked by uid 89); 24 May 2019 11:12:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.5 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 autolearn=ham version=3.3.1 spammy=H*r:0100, HX-Languages-Length:1500 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; Fri, 24 May 2019 11:12:27 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1hU87a-0003zm-Jf from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Fri, 24 May 2019 04:12:22 -0700 Received: from [127.0.0.1] (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 24 May 2019 12:12:19 +0100 To: "gcc-patches@gcc.gnu.org" From: Andrew Stubbs Subject: [committed, amdgcn] Fix stack initialization bug Message-ID: <2243eda5-2784-2330-396f-9a1e68ce155b@codesourcery.com> Date: Fri, 24 May 2019 12:12:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 This patch fixes a 64-bit arithmetic bug in which the wrong instruction was used for the lo-part resulting in an incorrect calculation for the hi-part (signed vs. unsigned add). This causes a Memory Access Fault whenever the launcher happens to choose a problematic address for the stack allocation. This problem never occurred on GCN3 because the launcher always chose addresses in the 32-bit range. It seems to happen more frequently on GCN5 devices since a recent ROCm update. Fix 64-bit addition in prologue. 2019-05-24 Andrew Stubbs gcc/ * config/gcn/gcn.c (gcn_expand_prologue): Use gen_addsi3_scalar_carry for lo-part. diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 47630c6edb4..71f4b4ce35a 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -2824,9 +2824,9 @@ gcn_expand_prologue () emit_move_insn (fp_lo, gen_rtx_REG (SImode, 0)); emit_insn (gen_andsi3_scc (fp_hi, gen_rtx_REG (SImode, 1), gen_int_mode (0xffff, SImode))); - emit_insn (gen_addsi3_scc (fp_lo, fp_lo, wave_offset)); - emit_insn (gen_addcsi3_scalar_zero (fp_hi, fp_hi, - gen_rtx_REG (BImode, SCC_REG))); + rtx scc = gen_rtx_REG (BImode, SCC_REG); + emit_insn (gen_addsi3_scalar_carry (fp_lo, fp_lo, wave_offset, scc)); + emit_insn (gen_addcsi3_scalar_zero (fp_hi, fp_hi, scc)); if (sp_adjust > 0) emit_insn (gen_adddi3_scc (sp, fp, gen_int_mode (sp_adjust, DImode)));