Skip to content

Commit

Permalink
tree-optimization/105185 - simplify modref query in SCCVN
Browse files Browse the repository at this point in the history
This simplifies the modref query for calls in SCCVN again after
r12-8019-g4be08315124281, avoiding an ICE when the modref
analyzed access lacks an actual argument on the caller side.
It effectively reverts r12-7531-gdc46350d44c294.

2022-04-07  Richard Biener  <[email protected]>

	PR tree-optimization/105185
	* tree-ssa-sccvn.cc (visit_reference_op_call): Simplify
	modref query again.

	* gcc.dg/torture/pr105185.c: New testcase.
  • Loading branch information
rguenth committed Apr 7, 2022
1 parent 024edf0 commit 27bfd13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions gcc/testsuite/gcc.dg/torture/pr105185.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* { dg-do compile } */

int foo (fmt)
char* fmt;
{
return (__builtin_strchr (fmt, '*') != 0
|| __builtin_strchr (fmt, 'n') != 0);
}
void bar ()
{
if (foo ())
__builtin_abort ();
}
5 changes: 2 additions & 3 deletions gcc/tree-ssa-sccvn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5140,12 +5140,11 @@ visit_reference_op_call (tree lhs, gcall *stmt)
{
accesses.quick_grow (accesses.length () + 1);
ao_ref *r = &accesses.last ();
tree arg = access_node.get_call_arg (stmt);
if (!POINTER_TYPE_P (TREE_TYPE (arg))
|| !access_node.get_ao_ref (stmt, r))
if (!access_node.get_ao_ref (stmt, r))
{
/* Initialize a ref based on the argument and
unknown offset if possible. */
tree arg = access_node.get_call_arg (stmt);
if (arg && TREE_CODE (arg) == SSA_NAME)
arg = SSA_VAL (arg);
if (arg
Expand Down

0 comments on commit 27bfd13

Please sign in to comment.