From patchwork Mon Oct 19 10:12:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 532213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 100A3140082 for ; Mon, 19 Oct 2015 21:12:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uD5Z8sNS; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=qR+KVymEfytOteUPD2qI35wojVNuNOMzul5UwZ70ScPy+5ZUNcIM1 gDSm1OTQMjsGEEH2yZb1HGv9kLsozs++Anh1GNJidxxFGUWxaTddh6gv1eOhOeWe 1O0HixgW9lmftQnyVb5oBc7/luhmvDQ7S/HyWpD6o6q5BRbLG2BMSE= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=UwVZdxLRsabcjNCspfUS2Udv3QA=; b=uD5Z8sNS04ouLwF5bq8i TOEIgLCj4SB3yqbJOYz0XVSmfbu5QFEdfCkRjtopwOTGZqq1iW45ysdaYnDYvBOz vhjeYPCnhX+sLBWNePcTtDOmoDKIzqwiQr/Byg2xGJPbjiL/ub+LDM8F7lZNthiV QSrgFKOStv+7Ff4OhUgNVI0= Received: (qmail 52618 invoked by alias); 19 Oct 2015 10:12:15 -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 51963 invoked by uid 89); 19 Oct 2015 10:12:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 19 Oct 2015 10:12:14 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E8D63AABE for ; Mon, 19 Oct 2015 10:12:09 +0000 (UTC) Date: Mon, 19 Oct 2015 12:12:10 +0200 From: Martin Jambor To: GCC Patches Subject: [hsa] Fix ICE in build_outer_var_ref within GPUKERNEL Message-ID: <20151019101210.GE7998@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, the following patch fixes a segfault when building an outer_ref which would be in GPUKERNEL context hwen lowering. In that case, we need to use the outer context od the GPUKERNEL container. Committed to the branch. Thanks, Martin 2015-10-19 Martin Jambor * omp-low.c (build_outer_var_ref): If outer ctx is GPUKERNEL, use its outer ctx. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 383f34a..5234a11 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1186,7 +1186,16 @@ build_outer_var_ref (tree var, omp_context *ctx) x = var; } else if (ctx->outer) - x = lookup_decl (var, ctx->outer); + { + omp_context *outer = ctx->outer; + if (gimple_code (outer->stmt) == GIMPLE_OMP_GPUKERNEL) + { + outer = outer->outer; + gcc_assert (outer + && gimple_code (outer->stmt) != GIMPLE_OMP_GPUKERNEL); + } + x = lookup_decl (var, outer); + } else if (is_reference (var)) /* This can happen with orphaned constructs. If var is reference, it is possible it is shared and as such valid. */