re PR middle-end/67222 (ICE in gimple_call_arg with bogus posix_memalign)

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.

From-SVN: r226969
This commit is contained in:
Marek Polacek 2015-08-18 13:41:27 +00:00 committed by Marek Polacek
parent ec8a2131b6
commit 41dd7cf747
5 changed files with 39 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2015-08-18 Marek Polacek <polacek@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.
2015-08-18 Robert Suchanek <robert.suchanek@imgtec.com>
* config/mips/mips-protos.h (mips_hard_regno_rename_ok): New prototype.

View File

@ -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;

View File

@ -1,3 +1,8 @@
2015-08-18 Marek Polacek <polacek@redhat.com>
PR middle-end/67222
* gcc.dg/torture/pr67222.c: New test.
2015-08-18 Robert Suchanek <robert.suchanek@imgtec.com>
* gcc.target/mips/interrupt_handler-bug-1.c: New test.

View File

@ -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);
}

View File

@ -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: