From patchwork Wed Sep 5 11:48:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 966327 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-485163-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="xV3MptIk"; 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 42527l0Mp5z9sCf for ; Wed, 5 Sep 2018 21:50:10 +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:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=JALg2xyPSz8XNDFHg1DhtQ8Fr+1HT wEO9IgznBPxgW26R0Z/Y+RhO/19Oi8QTBcMtkQhhhVhocr+lfbWCYYwht+HNkxHX 3L6rBvCbbwlSOx1qcKt+2FupLEdpc57dCDwdOtXMmkqXlY4OAtMlrNUI6LVdbF12 HQDFUoLkY+C6ZU= 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:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=aMpj6heRVtaMGmydD9jeypkyHN4=; b=xV3 MptIklvKcxaBP0wU0zA9Pai0UgxdJupSuAT/cemSq6sP8px0FOOvO/OxjSK35xWs MEJcdDlLgsA80q3l8CE8Y6RQ2keed6E1oVH8b9DkUPMdxb4RcLfYbXzYgqr5KPWX qBLBc4weqjPGuie3x1tWyNw9F4CS0aJNG+bPLp24= Received: (qmail 80749 invoked by alias); 5 Sep 2018 11:49:38 -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 80427 invoked by uid 89); 5 Sep 2018 11:49:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.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.2 spammy=Hx-languages-length:1763 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; Wed, 05 Sep 2018 11:49:23 +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 1fxWJ4-0005TS-0K from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 04:49:10 -0700 Received: from build6-trusty-cs.sje.mentorg.com (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; Wed, 5 Sep 2018 12:49:05 +0100 From: To: Subject: [PATCH 02/25] Propagate address spaces to builtins. Date: Wed, 5 Sep 2018 12:48:50 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 At present, pointers passed to builtin functions, including atomic operators, are stripped of their address space properties. This doesn't seem to be deliberate, it just omits to copy them. Not only that, but it forces pointer sizes to Pmode, which isn't appropriate for all address spaces. This patch attempts to correct both issues. It works for GCN atomics and GCN OpenACC gang-private variables. 2018-09-05 Andrew Stubbs Julian Brown gcc/ * builtins.c (get_builtin_sync_mem): Handle address spaces. --- gcc/builtins.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/builtins.c b/gcc/builtins.c index 58ea747..361361c 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5781,14 +5781,21 @@ static rtx get_builtin_sync_mem (tree loc, machine_mode mode) { rtx addr, mem; + int addr_space = TYPE_ADDR_SPACE (POINTER_TYPE_P (TREE_TYPE (loc)) + ? TREE_TYPE (TREE_TYPE (loc)) + : TREE_TYPE (loc)); + scalar_int_mode addr_mode = targetm.addr_space.address_mode (addr_space); - addr = expand_expr (loc, NULL_RTX, ptr_mode, EXPAND_SUM); - addr = convert_memory_address (Pmode, addr); + addr = expand_expr (loc, NULL_RTX, addr_mode, EXPAND_SUM); /* Note that we explicitly do not want any alias information for this memory, so that we kill all other live memories. Otherwise we don't satisfy the full barrier semantics of the intrinsic. */ - mem = validize_mem (gen_rtx_MEM (mode, addr)); + mem = gen_rtx_MEM (mode, addr); + + set_mem_addr_space (mem, addr_space); + + mem = validize_mem (mem); /* The alignment needs to be at least according to that of the mode. */ set_mem_align (mem, MAX (GET_MODE_ALIGNMENT (mode),