From patchwork Tue Feb 11 13:15:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 319280 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 582082C00A0 for ; Wed, 12 Feb 2014 00:15:30 +1100 (EST) 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=or3NFssyjhF+XVel tJTDFCULlWRXdbsOaBKz3xpVr9Lgl+Mp3ANXzES2cQVUCQTMICdFCnHRumhjpbLV 3G8zwRV6MqU8gcn1EbZgFQ3WPgmisNvG7LoGtycxAgbugAFaFLxHGTVDIBc9Opw3 vcCqL2aLdrWQ+vKKrJ5HZHhOKAg= 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=naUtZmsYwWlUm/mK/Ze3NC rGlxs=; b=x9IDuBgX6azt5WvrElVmPwDCIZ1U4JJUrKkWizqXIob1glpSjh1OQ4 3p+lZxtGKEm/9dHgTXOJ0bj0efVI100syW8y/bKPT0gQBQWFD1kOOrcEXorwLvAn 1MfPLZ2jmMz6nN5KOVVd4J+c8A0AqiqsVENjRCsW3nDHy3XH1Wee8= Received: (qmail 7379 invoked by alias); 11 Feb 2014 13:15:19 -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 7365 invoked by uid 89); 11 Feb 2014 13:15:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 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; Tue, 11 Feb 2014 13:15:17 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WDDBA-00009I-Mx from Thomas_Schwinge@mentor.com ; Tue, 11 Feb 2014 05:15:12 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 11 Feb 2014 05:15:12 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Tue, 11 Feb 2014 13:15:10 +0000 From: Thomas Schwinge To: Aldy Hernandez , Jakub Jelinek CC: Jason Merrill , gcc-patches , "Iyer, Balaji V" Subject: Re: [PING] [test case, patch] ICE in Cilk Plus structured block checker In-Reply-To: <87vbwlyg3h.fsf@kepler.schwinge.homeip.net> References: <521B8ECA.70806@redhat.com> <521D060E.9030601@redhat.com> <524C95F2.1010802@redhat.com> <52618287.8010705@redhat.com> <52740D59.50104@redhat.com> <5284FF25.7020401@redhat.com> <20131114170553.GD27813@tucnak.zalov.cz> <52850AB6.2070408@redhat.com> <20131114180147.GE27813@tucnak.zalov.cz> <5285790E.9050000@redhat.com> <20131115073757.GA892@tucnak.redhat.com> <52863CB4.50900@redhat.com> <528695CD.5080705@redhat.com> <87fvq5n81s.fsf@kepler.schwinge.homeip.net> <87r49kuass.fsf@kepler.schwinge.homeip.net> <87k3f0okfu.fsf@kepler.schwinge.homeip.net> <87a9f4gire.fsf@kepler.schwinge.homeip.net> <87lhy55q53.fsf@kepler.schwinge.homeip.net> <87vbwlyg3h.fsf@kepler.schwinge.homeip.net> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Tue, 11 Feb 2014 14:15:00 +0100 Message-ID: <87ioslyenf.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 11 Feb 2014 13:43:46 +0100, I wrote: > Ping again for test case and rather trivial patch to cure a GCC trunk ICE > in the Cilk Plus structured block checker if both -fcilkplus and -fopenmp > are specified. Jakub asked me to »please repost just the (hopefully small) trunk patch alone«, so here we go: Consider the following code: void baz() { bad1: #pragma omp parallel goto bad1; } Then, if both -fcilkplus and -fopenmp are specified, that will run into a SIGSEGV/ICE because of label_ctx == NULL in omp-low.c:diagnose_sb_0. The testcase is basically a concatenation of gcc.dg/cilk-plus/jump.c and gcc.dg/gomp/block-1.c -- should this be done differently/better? Fix potential ICE (null pointer dereference) in omp-low.c:diagnose_sb_0. gcc/ * omp-low.c (diagnose_sb_0): Make sure label_ctx is valid to dereference. gcc/testsuite/ * gcc.dg/cilk-plus/jump-openmp.c: New file. Grüße, Thomas diff --git gcc/omp-low.c gcc/omp-low.c index e0f7d1d..91221c0 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -10865,7 +10865,8 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p, if ((branch_ctx && gimple_code (branch_ctx) == GIMPLE_OMP_FOR && gimple_omp_for_kind (branch_ctx) == GF_OMP_FOR_KIND_CILKSIMD) - || (gimple_code (label_ctx) == GIMPLE_OMP_FOR + || (label_ctx + && gimple_code (label_ctx) == GIMPLE_OMP_FOR && gimple_omp_for_kind (label_ctx) == GF_OMP_FOR_KIND_CILKSIMD)) cilkplus_block = true; } diff --git gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c new file mode 100644 index 0000000..95e6b2d --- /dev/null +++ gcc/testsuite/gcc.dg/cilk-plus/jump-openmp.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -fopenmp" } */ +/* { dg-require-effective-target fopenmp } */ + +int *a, *b, c; + +void foo() +{ +#pragma simd + for (int i=0; i < 1000; ++i) + { + a[i] = b[i]; + if (c == 5) + return; /* { dg-error "invalid branch to/from a Cilk Plus structured block" } */ + } +} + +void bar() +{ +#pragma simd + for (int i=0; i < 1000; ++i) + { + lab: + a[i] = b[i]; + } + if (c == 6) + goto lab; /* { dg-error "invalid entry to Cilk Plus structured block" } */ +} + +void baz() +{ + bad1: + #pragma omp parallel + goto bad1; /* { dg-error "invalid branch to/from an OpenMP structured block" } */ + + goto bad2; /* { dg-error "invalid entry to OpenMP structured block" } */ + #pragma omp parallel + { + bad2: ; + } + + #pragma omp parallel + { + int i; + goto ok1; + for (i = 0; i < 10; ++i) + { ok1: break; } + } +}