From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72977 invoked by alias); 2 Sep 2015 13:45:40 -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 72928 invoked by uid 89); 2 Sep 2015 13:45:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 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; Wed, 02 Sep 2015 13:45:38 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8D3E6ACCA; Wed, 2 Sep 2015 13:45:35 +0000 (UTC) Date: Wed, 02 Sep 2015 13:45:00 -0000 From: Richard Biener To: Jan Hubicka cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR66705 In-Reply-To: Message-ID: References: <20150902130338.GA96189@kam.mff.cuni.cz> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2015-09/txt/msg00156.txt.bz2 On Wed, 2 Sep 2015, Richard Biener wrote: > On Wed, 2 Sep 2015, Jan Hubicka wrote: > > > > > > > I was naiively using ->get_constructor in IPA PTA without proper > > > checking on wheter that succeeds. Now I tried to use ctor_for_folding > > > but that isn't good as we want to analyze non-const globals in IPA > > > PTA and we need to analyze their initialiers as well. > > > > > > Thus I'm trying below with ctor_for_analysis, but I really "just" > > > need the initializer or a "not available" for conservative handling. > > > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > > > Honza - I suppose you should doble-check this and suggest sth > > > different (or implement sth more generic in the IPA infrastructure). > > > > Yep, you are correct that we don't currently have way to look into ctor > > without actually loading. But do you need something more than just walking > > references that you already have in ipa-ref lists? > > Hmm, no, ipa-ref list should be enough (unless we start field-sensitive > analysis or need NULL inits for correctness). Still have to figure out > how to walk the list and how the reference would look like (what > is ref->use? IPA_REF_ADDR? can those be speculative?) Sth like the following seems to work. Richard. 2015-09-02 Richard Biener PR ipa/66705 * tree-ssa-structalias.c (ctor_for_analysis): New function. (create_variable_info_for_1): Use ctor_for_analysis instead of get_constructor. (create_variable_info_for): Likewise. * g++.dg/lto/pr66705_0.C: New testcase. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 227207) +++ gcc/tree-ssa-structalias.c (working copy) @@ -5650,7 +5650,6 @@ create_variable_info_for_1 (tree decl, c auto_vec fieldstack; fieldoff_s *fo; unsigned int i; - varpool_node *vnode; if (!declsize || !tree_fits_uhwi_p (declsize)) @@ -5668,12 +5667,10 @@ create_variable_info_for_1 (tree decl, c /* Collect field information. */ if (use_field_sensitive && var_can_have_subvars (decl) - /* ??? Force us to not use subfields for global initializers - in IPA mode. Else we'd have to parse arbitrary initializers. */ + /* ??? Force us to not use subfields for globals in IPA mode. + Else we'd have to parse arbitrary initializers. */ && !(in_ipa_mode - && is_global_var (decl) - && (vnode = varpool_node::get (decl)) - && vnode->get_constructor ())) + && is_global_var (decl))) { fieldoff_s *fo = NULL; bool notokay = false; @@ -5805,13 +5802,13 @@ create_variable_info_for (tree decl, con /* If this is a global variable with an initializer and we are in IPA mode generate constraints for it. */ - if (vnode->get_constructor () - && vnode->definition) + ipa_ref *ref; + for (unsigned idx = 0; vnode->iterate_reference (idx, ref); ++idx) { auto_vec rhsc; struct constraint_expr lhs, *rhsp; unsigned i; - get_constraint_for_rhs (vnode->get_constructor (), &rhsc); + get_constraint_for_address_of (ref->referred->decl, &rhsc); lhs.var = vi->id; lhs.offset = 0; lhs.type = SCALAR; Index: gcc/testsuite/g++.dg/lto/pr66705_0.C =================================================================== --- gcc/testsuite/g++.dg/lto/pr66705_0.C (revision 0) +++ gcc/testsuite/g++.dg/lto/pr66705_0.C (working copy) @@ -0,0 +1,15 @@ +// { dg-lto-do link } +// { dg-lto-options { { -O2 -flto -flto-partition=max -fipa-pta } } } +// { dg-extra-ld-options "-r -nostdlib" } + +class A { +public: + A(); +}; +int a = 0; +void foo() { + a = 0; + A b; + for (; a;) + ; +}