public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] Fix PR66705
Date: Wed, 02 Sep 2015 13:03:00 -0000	[thread overview]
Message-ID: <20150902130338.GA96189@kam.mff.cuni.cz> (raw)
In-Reply-To: <alpine.LSU.2.11.1509021456160.5523@zhemvz.fhfr.qr>

> 
> 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?
> 
> Thanks,
> Richard.
> 
> 2015-09-02  Richard Biener  <rguenther@suse.de>
> 
> 	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.

Otherwise I would go for making ctor_for_analysis a method of varpool_node and...
> 
> 	* 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)
> @@ -5637,6 +5637,26 @@ check_for_overlaps (vec<fieldoff_s> fiel
>    return false;
>  }
>  
> +/* We can't use ctor_for_folding as that only returns constant constructors.  */
> +
> +static tree
> +ctor_for_analysis (tree decl)
> +{
> +  varpool_node *node = varpool_node::get (decl);
> +  if (!node)
> +    return error_mark_node;
> +  node = node->ultimate_alias_target ();
> +  if (DECL_INITIAL (node->decl) != error_mark_node
> +      || !in_lto_p)
> +    return (DECL_INITIAL (node->decl)
> +	    ? DECL_INITIAL (node->decl) : error_mark_node);

I think returning NULL here is just fine. 
error_mark_node means constructor is not really available. NULL is
the usual way to say that the variable is not initialized.

  reply	other threads:[~2015-09-02 13:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 12:59 Richard Biener
2015-09-02 13:03 ` Jan Hubicka [this message]
2015-09-02 13:32   ` Richard Biener
2015-09-02 13:45     ` Richard Biener
2015-09-02 14:23       ` Jan Hubicka
2015-09-02 14:31         ` Richard Biener
2015-09-03  8:54           ` Jan Hubicka
2015-09-02 14:25     ` Jan Hubicka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150902130338.GA96189@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).