On Tue, Aug 18, 2015 at 1:10 PM, Marek Polacek <pola...@redhat.com> wrote: > On Tue, Aug 18, 2015 at 12:47:45PM +0200, Richard Biener wrote: >> Please instead change the tree-ssa-alias.c code to do >> >> if (callee != NULL >> && gimple_call_builtin_p (call, BUILT_IN_NORMAL)) >> switch (DECL_FUNCTION_CODE (callee)) >> ... > > Ok. I see that works as well because gimple_call_builtin_p uses > gimple_builtin_call_types_compatible_p. > >> which should also fix quite a few issues in the other builtin handlings. >> Likewise can you change stmt_kills_ref_p and ref_maybe_used_by_call_p_1 >> in a similar way? > > Sure. Regtest/bootstrap running, ok for trunk/5 if it passes?
Ok. Thanks, Richard. > 2015-08-18 Marek Polacek <pola...@redhat.com> > > PR middle-end/67222 > * gimple-low.c (lower_stmt): Don't lower BUILT_IN_POSIX_MEMALIGN > if the call isn't valid. > * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Check builtins using > gimple_call_builtin_p. > (call_may_clobber_ref_p_1): Likewise. > (stmt_kills_ref_p): Likewise. > > * gcc.dg/torture/pr67222.c: New test. > > diff --git gcc/gimple-low.c gcc/gimple-low.c > index d4697e2..4eae3a0 100644 > --- gcc/gimple-low.c > +++ gcc/gimple-low.c > @@ -346,7 +346,8 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data > *data) > return; > } > else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_POSIX_MEMALIGN > - && flag_tree_bit_ccp) > + && flag_tree_bit_ccp > + && gimple_builtin_call_types_compatible_p (stmt, decl)) > { > lower_builtin_posix_memalign (gsi); > return; > diff --git gcc/testsuite/gcc.dg/torture/pr67222.c > gcc/testsuite/gcc.dg/torture/pr67222.c > index e69de29..739f869 100644 > --- gcc/testsuite/gcc.dg/torture/pr67222.c > +++ gcc/testsuite/gcc.dg/torture/pr67222.c > @@ -0,0 +1,19 @@ > +/* PR middle-end/67222 */ > +/* { dg-do compile } */ > + > +void > +foo (void **p) > +{ > + posix_memalign (); /* { dg-warning "implicit declaration" } */ > + posix_memalign (p); > + posix_memalign (0); > + posix_memalign (p, 1); > + posix_memalign (p, "foo"); > + posix_memalign ("gnu", "gcc"); > + posix_memalign (1, p); > + posix_memalign (1, 2); > + posix_memalign (1, 2, 3); > + posix_memalign (p, p, p); > + posix_memalign (p, "qui", 3); > + posix_memalign (p, 1, 2); > +} > diff --git gcc/tree-ssa-alias.c gcc/tree-ssa-alias.c > index e103220..0445052 100644 > --- gcc/tree-ssa-alias.c > +++ gcc/tree-ssa-alias.c > @@ -1535,7 +1535,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref) > escape points. See tree-ssa-structalias.c:find_func_aliases > for the list of builtins we might need to handle here. */ > if (callee != NULL_TREE > - && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) > + && gimple_call_builtin_p (call, BUILT_IN_NORMAL)) > switch (DECL_FUNCTION_CODE (callee)) > { > /* All the following functions read memory pointed to by > @@ -1941,7 +1941,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref) > escape points. See tree-ssa-structalias.c:find_func_aliases > for the list of builtins we might need to handle here. */ > if (callee != NULL_TREE > - && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) > + && gimple_call_builtin_p (call, BUILT_IN_NORMAL)) > switch (DECL_FUNCTION_CODE (callee)) > { > /* All the following functions clobber memory pointed to by > @@ -2341,7 +2341,7 @@ stmt_kills_ref_p (gimple stmt, ao_ref *ref) > { > tree callee = gimple_call_fndecl (stmt); > if (callee != NULL_TREE > - && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) > + && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) > switch (DECL_FUNCTION_CODE (callee)) > { > case BUILT_IN_FREE: > > Marek