From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95670 invoked by alias); 1 Jun 2016 14:37:45 -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 95658 invoked by uid 89); 1 Jun 2016 14:37:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ort, copyout X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 01 Jun 2016 14:37:43 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9044346266 for ; Wed, 1 Jun 2016 14:37:42 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u51Ebf8i023329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 1 Jun 2016 10:37:42 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u51EbdkO024191 for ; Wed, 1 Jun 2016 16:37:39 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u51EbcxD024190 for gcc-patches@gcc.gnu.org; Wed, 1 Jun 2016 16:37:38 +0200 Date: Wed, 01 Jun 2016 14:37:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix ICE with OpenMP taskloop (PR middle-end/71371) Message-ID: <20160601143738.GR28550@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00050.txt.bz2 Hi! I've committed following patch to fix ICE on taskloop construct where the IV is addressable. This doesn't ICE on for, simd or distribute because it is ORT_WORKSHARE or ORT_SIMD and thus omp_add_variable during create_tmp_var is called in outer context. While it doesn't hurt in that case, as we want to make the var just private or linear in the current context (the latter without copyin and copyout), it is better not to call omp_add_variable on it during create_tmp_var at all (we call it a few lines later with the right flags). Using create_tmp_var_raw would work too, but we'd have to manually do all the rest of gimple_add_tmp_var except for omp_add_variable. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 6.2. 2016-06-01 Jakub Jelinek PR middle-end/71371 * gimplify.c (gimplify_omp_for): Temporarily clear gimplify_omp_ctxp around creation of the temporary. * c-c++-common/gomp/pr71371.c: New test. --- gcc/gimplify.c.jj 2016-05-26 10:38:02.000000000 +0200 +++ gcc/gimplify.c 2016-06-01 13:27:23.647789536 +0200 @@ -9007,7 +9007,12 @@ gimplify_omp_for (tree *expr_p, gimple_s || (ort == ORT_SIMD && TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) > 1)) { + struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; + /* Make sure omp_add_variable is not called on it prematurely. + We call it ourselves a few lines later. */ + gimplify_omp_ctxp = NULL; var = create_tmp_var (TREE_TYPE (decl), get_name (decl)); + gimplify_omp_ctxp = ctx; TREE_OPERAND (t, 0) = var; gimplify_seq_add_stmt (&for_body, gimple_build_assign (decl, var)); --- gcc/testsuite/c-c++-common/gomp/pr71371.c.jj 2016-06-01 13:35:18.639633280 +0200 +++ gcc/testsuite/c-c++-common/gomp/pr71371.c 2016-06-01 13:35:37.366390567 +0200 @@ -0,0 +1,25 @@ +/* PR middle-end/71371 */ +/* { dg-do compile } */ + +void baz (int *); + +void +foo (void) +{ + int i; + #pragma omp taskloop + for (i = 0; i < 100; i++) + baz (&i); +} + +void +bar (void) +{ + int i; + #pragma omp parallel + { + #pragma omp for + for (i = 0; i < 100; i++) + baz (&i); + } +} Jakub