From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13648 invoked by alias); 22 Jun 2011 18:00:47 -0000 Received: (qmail 13639 invoked by uid 22791); 22 Jun 2011 18:00:46 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Jun 2011 18:00:32 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 100EB8980B for ; Wed, 22 Jun 2011 20:00:31 +0200 (CEST) Date: Wed, 22 Jun 2011 18:13:00 -0000 From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR49493 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 X-SW-Source: 2011-06/txt/msg01691.txt.bz2 This fixes PR49493. Bootstrapped and tested on x86_64-unknown-linx-gnu, committed. Richard. 2011-06-22 Richard Guenther PR tree-optimization/49493 * tree-ssa-structalias.c (get_constraint_for_ssa_var): Refer to the alias target of variables. (associate_varinfo_to_alias_1): Remove. (ipa_pta_execute): Do not associate aliases with anything. * cgraph.h (varpool_alias_aliased_node): Fix cut&paste errors. (cgraph_function_node): Likewise. (cgraph_function_or_thunk_node): Likewise. (varpool_variable_node): Likewise. * gcc.dg/ipa/ipa-pta-17.c: New testcase. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 175294) +++ gcc/tree-ssa-structalias.c (working copy) @@ -2746,6 +2746,18 @@ get_constraint_for_ssa_var (tree t, VEC( return; } + /* For global variables resort to the alias target. */ + if (TREE_CODE (t) == VAR_DECL + && (TREE_STATIC (t) || DECL_EXTERNAL (t))) + { + struct varpool_node *node = varpool_get_node (t); + if (node && node->alias) + { + node = varpool_variable_node (node, NULL); + t = node->decl; + } + } + vi = get_vi_for_tree (t); cexpr.var = vi->id; cexpr.type = SCALAR; @@ -6703,16 +6751,6 @@ associate_varinfo_to_alias (struct cgrap return false; } -/* Associate node with varinfo DATA. Worker for - varpool_for_node_and_aliases. */ -static bool -associate_varinfo_to_alias_1 (struct varpool_node *node, void *data) -{ - if (node->alias) - insert_vi_for_tree (node->decl, (varinfo_t)data); - return false; -} - /* Execute the driver for IPA PTA. */ static unsigned int ipa_pta_execute (void) @@ -6744,12 +6788,10 @@ ipa_pta_execute (void) /* Create constraints for global variables and their initializers. */ for (var = varpool_nodes; var; var = var->next) { - varinfo_t vi; if (var->alias) continue; - vi = get_vi_for_tree (var->decl); - varpool_for_node_and_aliases (var, associate_varinfo_to_alias_1, vi, true); + get_vi_for_tree (var->decl); } if (dump_file) Index: gcc/cgraph.h =================================================================== --- gcc/cgraph.h (revision 175294) +++ gcc/cgraph.h (working copy) @@ -981,7 +981,7 @@ varpool_alias_aliased_node (struct varpo ipa_ref_list_reference_iterate (&n->ref_list, 0, ref); gcc_checking_assert (ref->use == IPA_REF_ALIAS); - if (ref->refered_type == IPA_REF_CGRAPH) + if (ref->refered_type == IPA_REF_VARPOOL) return ipa_ref_varpool_node (ref); return NULL; } @@ -1011,7 +1011,7 @@ cgraph_function_node (struct cgraph_node *availability = a; } } - if (*availability) + if (availability) *availability = AVAIL_NOT_AVAILABLE; return NULL; } @@ -1039,7 +1039,7 @@ cgraph_function_or_thunk_node (struct cg *availability = a; } } - if (*availability) + if (availability) *availability = AVAIL_NOT_AVAILABLE; return NULL; } @@ -1067,7 +1067,7 @@ varpool_variable_node (struct varpool_no *availability = a; } } - if (*availability) + if (availability) *availability = AVAIL_NOT_AVAILABLE; return NULL; } Index: gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c =================================================================== --- gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c (revision 0) +++ gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c (revision 0) @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-pta" } */ + +static int i; +extern int j __attribute__ ((alias ("i"))); +int *p = &j;