From patchwork Mon May 2 06:53:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 617379 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 3qyw5L63pTz9t6W for ; Mon, 2 May 2016 16:54:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ru+wbEG1; 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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Ea0skp+AIg2zZa2qu5Ajgbz+Q/tk74JvaTwJTVh0T9UAQtmZgX 3HOTunLCl64b9ktCc8fqy5IgC+5TLNp0kP0HJO1QsarD2XgUGrgsGJw/mBtVTE11 w7odY3eNurt/jhgwiPSbNlXwHyA1p3pdQTbw/QqYPGJcHOPP7EOoBM8FI= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=oleLFi37Xr8FxknvdMDsr3tiNNQ=; b=ru+wbEG1h2zNGrKOTEej Vw7Ahjj3lZnH/SsxnS1FkifV6B6X3Q+yobk5YKRGmFz2pyeDcaunK5UfGUtOpTyT +OuApm2a0Dya8Ujfo7c/fNaWK0Cgz8fGCw9miGbnybHCRUGTCvf/jD+yAKzV2ckR RminiVhI9W5wGjVt0oC7j4E= Received: (qmail 48192 invoked by alias); 2 May 2016 06:54:04 -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 48066 invoked by uid 89); 2 May 2016 06:54:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-05-02, graphs, Hx-languages-length:2433, 20160502 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 02 May 2016 06:53:53 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ax7jp-0006lY-2m from Tom_deVries@mentor.com ; Sun, 01 May 2016 23:53:49 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 2 May 2016 07:53:47 +0100 To: Richard Biener CC: GCC Patches , Marek Polacek From: Tom de Vries Subject: [PATCH, PR70700] Fix ICE in dump_pred_graph Message-ID: <5726F960.9020300@mentor.com> Date: Mon, 2 May 2016 08:53:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 Hi, this patch fixes PR70700, an ICE in tree-ssa-structalias.c:dump_pred_graph for the test-case contained in the patch. In the constraint graph, a node representing a variable varinfo_t var is represented as the corresponding var->id, ranging from 1 to FIRST_REF_NODE - 1. A node representing a DEREF of a varinfo_t var is represented as the corresponding var->id + FIRST_REF_NODE, ranging from FIRST_REF_NODE + 1 to LAST_REF_NODE. So, for a DEREF node, we need to substract FIRST_REF_NODE to find the corresponding variable. This logic is missing in a print statement in dump_pred_graph (which is triggered with TDF_GRAPH), which causes the ICE. This patch fixes the ICE by substracting FIRST_REF_NODE from the node number of a DEREF node to find the varinfo, and prints it as a DEREF node (by adding an '*' prefix). Bootstrapped and reg-tested on x86_64. Extracted graphs from ealias dump and verified that valid pdfs were produced. OK for trunk? Thanks, - Tom Fix ICE in dump_pred_graph 2016-05-02 Marek Polacek Tom de Vries PR tree-optimization/70700 * tree-ssa-structalias.c (dump_pred_graph): Fix getting varinfo for ids bigger than FIRST_REF_NODE. * gcc.dg/pr70700.c: New test. --- gcc/testsuite/gcc.dg/pr70700.c | 15 +++++++++++++++ gcc/tree-ssa-structalias.c | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr70700.c b/gcc/testsuite/gcc.dg/pr70700.c new file mode 100644 index 0000000..613cd29 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70700.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ealias-graph" } */ + +struct S +{ + long m; +}; + +struct S +fn1 (struct S *a) +{ + if (a->m) + a->m |= 2; + return *a; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 0a41494..d66bdfa 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -2241,7 +2241,11 @@ dump_pred_graph (struct scc_info *si, FILE *file) if (graph->points_to[i] && !bitmap_empty_p (graph->points_to[i])) { - fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); + if (i < FIRST_REF_NODE) + fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); + else + fprintf (file, "[label=\"*%s = {", + get_varinfo (i - FIRST_REF_NODE)->name); unsigned j; bitmap_iterator bi; EXECUTE_IF_SET_IN_BITMAP (graph->points_to[i], 0, j, bi)