From: Jan Hubicka <hubicka@ucw.cz>
To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Cc: Jan Hubicka <hubicka@ucw.cz>, Richard Biener <rguenther@suse.de>,
Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>,
gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] ipa bitwise constant propagation
Date: Fri, 12 Aug 2016 14:04:00 -0000 [thread overview]
Message-ID: <20160812140347.GC68714@kam.mff.cuni.cz> (raw)
In-Reply-To: <CAAgBjM=mtVSgi-91uX-gfVy9wAU9mVqwVDcdxKCq+L3cM40KJg@mail.gmail.com>
> On 11 August 2016 at 18:25, Jan Hubicka <hubicka@ucw.cz> wrote:
> >> @@ -266,6 +267,38 @@ private:
> >> bool meet_with_1 (unsigned new_align, unsigned new_misalign);
> >> };
> >>
> >> +/* Lattice of known bits, only capable of holding one value.
> >> + Similar to ccp_lattice_t, mask represents which bits of value are constant.
> >> + If a bit in mask is set to 0, then the corresponding bit in
> >> + value is known to be constant. */
> >> +
> >> +class ipcp_bits_lattice
> >> +{
> >> +public:
> >> + bool bottom_p () { return m_lattice_val == IPA_BITS_VARYING; }
> >> + bool top_p () { return m_lattice_val == IPA_BITS_UNDEFINED; }
> >> + bool constant_p () { return m_lattice_val == IPA_BITS_CONSTANT; }
> >> + bool set_to_bottom ();
> >> + bool set_to_constant (widest_int, widest_int);
> >> +
> >> + widest_int get_value () { return m_value; }
> >> + widest_int get_mask () { return m_mask; }
> >> +
> >> + bool meet_with (ipcp_bits_lattice& other, unsigned, signop,
> >> + enum tree_code, tree);
> >> +
> >> + bool meet_with (widest_int, widest_int, unsigned);
> >> +
> >> + void print (FILE *);
> >> +
> >> +private:
> >> + enum { IPA_BITS_UNDEFINED, IPA_BITS_CONSTANT, IPA_BITS_VARYING } m_lattice_val;
> >> + widest_int m_value, m_mask;
> >
> > Please add comment for these, like one in tree-ssa-ccp and mention they are the same
> > values.
> >
> >> +
> >> + /* For K&R C programs, ipa_get_type() could return NULL_TREE.
> >> + Avoid the transform for these cases. */
> >> + if (!parm_type)
> >> + return dest_lattice->set_to_bottom ();
> >
> > Please add TDF_DETAILS dump for this so we notice if we drop useful info for no
> > good reasons. It also happens for variadic functions but hopefully not much more.
> >
> > The patch is OK with those changes.
> Hi,
> The patch broke bootstrap due to segfault while compiling libsupc++/eh_alloc.cc
> in ipa_get_type() because callee_info->descriptors had 0 length in
> propagate_bits_accross_call.
>
> After debugging a bit, I realized it was incorrect to use cs->callee and
> using cs->callee->function_symbol() fixed it:
> (that seemed to match with value of 'callee' variable in
> propagate_constants_accross_call).
Yes, callee may be alias and in that case you want to look into its target.
>
> - struct ipa_node_params *callee_info = IPA_NODE_REF (cs->callee);
> + enum availability availability;
> + cgraph_node *callee = cs->callee->function_symbol (&availability);
> + struct ipa_node_params *callee_info = IPA_NODE_REF (callee);
> tree parm_type = ipa_get_type (callee_info, idx);
>
> Similarly I wonder if cs->caller->function_symbol() should be used
> instead of cs->caller in following place while obtaining lattices of
> source param ?
>
> if (jfunc->type == IPA_JF_PASS_THROUGH)
> {
> struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
For callers you do not need to do that, because only real functions can call
(not aliases).
>
>
> The patch segfaults with -flto for gcc.c-torture/execute/920302-1.c in
> ipcp_propagate_stage ()
> while populating info->descriptors[k].decl_or_type because t becomes
> NULL and we dereference
> it with TREE_VALUE (t)
> The test-case has K&R style param declaration.
> The following change seems to fix it for me:
>
> @@ -3235,7 +3235,7 @@ ipcp_propagate_stage (struct ipa_topo_info *topo)
> if (in_lto_p)
> {
> tree t = TYPE_ARG_TYPES (TREE_TYPE (node->decl));
> - for (int k = 0; k < ipa_get_param_count (info); k++)
> + for (int k = 0; k < ipa_get_param_count (info) && t; k++)
> {
> gcc_assert (t != void_list_node);
> info->descriptors[k].decl_or_type = TREE_VALUE (t);
>
> Is that change OK ?
Yes, this also looks fine to me.
Honza
>
> PS: I am on vacation for next week, will get back to working on the
> patch after returning.
>
> Thanks,
> Prathamesh
> >
> > thanks,
> > Honza
next prev parent reply other threads:[~2016-08-12 14:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 6:36 Prathamesh Kulkarni
2016-08-04 8:02 ` Richard Biener
2016-08-04 8:57 ` Prathamesh Kulkarni
2016-08-04 9:07 ` kugan
2016-08-04 10:51 ` Richard Biener
2016-08-04 13:05 ` Jan Hubicka
2016-08-04 23:04 ` kugan
2016-08-05 11:36 ` Jan Hubicka
2016-08-05 12:37 ` Martin Jambor
2016-08-07 21:38 ` Prathamesh Kulkarni
2016-08-08 14:04 ` Martin Jambor
2016-08-08 14:29 ` David Malcolm
2016-08-09 8:11 ` Prathamesh Kulkarni
2016-08-09 9:24 ` Richard Biener
2016-08-09 11:09 ` Martin Jambor
2016-08-09 11:47 ` Prathamesh Kulkarni
2016-08-09 18:13 ` Martin Jambor
2016-08-10 8:45 ` Prathamesh Kulkarni
2016-08-10 11:35 ` Prathamesh Kulkarni
2016-08-11 12:55 ` Jan Hubicka
2016-08-12 9:54 ` Prathamesh Kulkarni
2016-08-12 14:04 ` Jan Hubicka [this message]
2016-08-16 13:05 ` Prathamesh Kulkarni
2016-08-22 13:33 ` Martin Jambor
2016-08-22 13:55 ` Prathamesh Kulkarni
2016-08-24 12:07 ` Prathamesh Kulkarni
2016-08-25 13:44 ` Jan Hubicka
2016-08-26 12:31 ` Prathamesh Kulkarni
2016-08-26 16:23 ` Rainer Orth
2016-08-26 17:23 ` Prathamesh Kulkarni
2016-08-29 10:53 ` Christophe Lyon
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=20160812140347.GC68714@kam.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=kugan.vivekanandarajah@linaro.org \
--cc=prathamesh.kulkarni@linaro.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).