From patchwork Thu Jun 30 09:13:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 642453 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 3rgDP06Nkvz9sdQ for ; Thu, 30 Jun 2016 19:13:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FbUY0R5L; 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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=NgVZOE/ZfD2rMMc+9PAyPrV3sz6nreTMxzmR848x4cNjpbEyFb nBw0tP6krQ5oiIyrpac3UvTw6HvO5qBpjbcCzsAh11qNiH+2ZWN1gceoGj3h3ghQ LRei9C3nR+fkWbIdmHdVxVJyPZBEwxetsAxjDCr2ygr5Kvv6ibg/5u+W4= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=Cvrid+I2FXrQj0a0DKms1vqExxI=; b=FbUY0R5LGCTKCemWw9gC RjkQYdN9QiKepgf40y2ECQysMwTW7Urr/L+IDNIzQwp1K7U0X6oHp69hWqUwTDsh 3be/YqjudfwJUbPEqQszeSCr7kvjAyZaSjqP1oXxjsQrXRZ38qsmJClb3tMN8Rb5 e5O7PlfHZbQZliOjvsxIyIg= Received: (qmail 41825 invoked by alias); 30 Jun 2016 09:13:31 -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 41815 invoked by uid 89); 30 Jun 2016 09:13:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=D*cz, D*suse.cz, our 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; Thu, 30 Jun 2016 09:13:20 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A079FABDF for ; Thu, 30 Jun 2016 09:13:17 +0000 (UTC) Date: Thu, 30 Jun 2016 11:13:17 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: Fix PR fortran/71688 Message-ID: <20160630091317.qlwmkyotntw2kvsa@virgil.suse.cz> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1-neo (2016-06-11) X-IsSubscribed: yes Hi, PR 71688 is about an ICE in cgraphunit.c caused by the fact that Fortran FE creates two separate call-graph nodes for a single function decl, if you are interested, complete backtraces leading to the point of creating them are in bugzilla. The intuitive fix, changing one of these points so that they call cgraph::get_create rather than cgraph_node::create works and given the comment just before the line also seems like the correct thing to do: /* Register this function with cgraph just far enough to get it added to our parent's nested function list. If there are static coarrays in this function, the nested _caf_init function has already called cgraph_create_node, which also created the cgraph node for this function. */ It is interesting that the bug lurked so long there. I have bootstrapped and tested the patch below on x86_64-linux, is it OK for trunk and (after a while) for all active release branches? Thanks, Martin 2016-06-29 Martin Jambor PR fortran/71688 * trans-decl.c (gfc_generate_function_code): Use get_create rather than create to get a call graph node. testsuite/ gfortran.dg/pr71688.f90: New test. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 2f5e434..0e68736 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -6336,7 +6336,7 @@ gfc_generate_function_code (gfc_namespace * ns) function has already called cgraph_create_node, which also created the cgraph node for this function. */ if (!has_coarray_vars || flag_coarray != GFC_FCOARRAY_LIB) - (void) cgraph_node::create (fndecl); + (void) cgraph_node::get_create (fndecl); } else cgraph_node::finalize_function (fndecl, true); diff --git a/gcc/testsuite/gfortran.dg/pr71688.f90 b/gcc/testsuite/gfortran.dg/pr71688.f90 new file mode 100644 index 0000000..dbb6d18 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr71688.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } + +program p + call s +contains + subroutine s + real :: x[*] = 1 + block + end block + x = 2 + end +end