On Tue, Jan 7, 2014 at 7:27 PM, Martin Jambor <mjam...@suse.cz> wrote: > Hi, > > I forgot to put the optimize test to the ipa_compute_jump_functions > when fixing PR 57358 which is where it is most necessary. This patch > adds it there and to parm_preserved_before_stmt_p which is also > reachable through ipa_load_from_parm_agg_1 that is also called from > outside of jump function computations. > > I'm currently bootstrapping and testing the following on x86_64-linux. > OK for the branch if it passes? And the testcase for trunk?
Ok. Thanks, Richard. > Thanks, > > Martin > > > 2014-01-07 Martin Jambor <mjam...@suse.cz> > > PR ipa/59610 > * ipa-prop.c (ipa_compute_jump_functions): Bail out if not optimizing. > (parm_preserved_before_stmt_p): Assume modification present when not > optimizing. > > testsuite/ > * gcc.dg/ipa/pr59610.c: New test. > > diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c > index 47d487d..3788a11 100644 > --- a/gcc/ipa-prop.c > +++ b/gcc/ipa-prop.c > @@ -623,16 +623,22 @@ parm_preserved_before_stmt_p (struct > param_analysis_info *parm_ainfo, > if (parm_ainfo && parm_ainfo->parm_modified) > return false; > > - gcc_checking_assert (gimple_vuse (stmt) != NULL_TREE); > - ao_ref_init (&refd, parm_load); > - /* We can cache visited statements only when parm_ainfo is available and > when > - we are looking at a naked load of the whole parameter. */ > - if (!parm_ainfo || TREE_CODE (parm_load) != PARM_DECL) > - visited_stmts = NULL; > + if (optimize) > + { > + gcc_checking_assert (gimple_vuse (stmt) != NULL_TREE); > + ao_ref_init (&refd, parm_load); > + /* We can cache visited statements only when parm_ainfo is available > and > + when we are looking at a naked load of the whole parameter. */ > + if (!parm_ainfo || TREE_CODE (parm_load) != PARM_DECL) > + visited_stmts = NULL; > + else > + visited_stmts = &parm_ainfo->parm_visited_statements; > + walk_aliased_vdefs (&refd, gimple_vuse (stmt), mark_modified, > &modified, > + visited_stmts); > + } > else > - visited_stmts = &parm_ainfo->parm_visited_statements; > - walk_aliased_vdefs (&refd, gimple_vuse (stmt), mark_modified, &modified, > - visited_stmts); > + modified = true; > + > if (parm_ainfo && modified) > parm_ainfo->parm_modified = true; > return !modified; > @@ -1466,6 +1472,9 @@ ipa_compute_jump_functions (struct cgraph_node *node, > { > struct cgraph_edge *cs; > > + if (!optimize) > + return; > + > for (cs = node->callees; cs; cs = cs->next_callee) > { > struct cgraph_node *callee = cgraph_function_or_thunk_node (cs->callee, > diff --git a/gcc/testsuite/gcc.dg/ipa/pr59610.c > b/gcc/testsuite/gcc.dg/ipa/pr59610.c > new file mode 100644 > index 0000000..fc09334 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/ipa/pr59610.c > @@ -0,0 +1,11 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +struct A { int a; }; > +extern void *y; > + > +__attribute__((optimize (0))) void > +foo (void *p, struct A x) > +{ > + foo (y, x); > +}