re PR tree-optimization/64121 (ICE: SSA corruption with -O -fsanitize=undefined)

PR sanitizer/64121
	* ubsan.c (instrument_object_size): Stop searching if the base
	occurs in abnormal phi.

	* c-c++-common/ubsan/pr64121.c: New test.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r218222
This commit is contained in:
Marek Polacek 2014-12-01 15:37:55 +00:00 committed by Marek Polacek
parent 0b274c179f
commit 7d1f4ae5f1
4 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2014-12-01 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR sanitizer/64121
* ubsan.c (instrument_object_size): Stop searching if the base
occurs in abnormal phi.
2014-12-01 Marek Polacek <polacek@redhat.com>
PR sanitizer/63956

View File

@ -1,3 +1,8 @@
2014-12-01 Marek Polacek <polacek@redhat.com>
PR sanitizer/64121
* c-c++-common/ubsan/pr64121.c: New test.
2014-12-01 Marek Polacek <polacek@redhat.com>
PR sanitizer/63956

View File

@ -0,0 +1,16 @@
/* PR sanitizer/64121 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined -Wno-pointer-arith" } */
extern int tab[16];
void
execute (int *ip, int x)
{
int *xp = tab;
base:
if (x)
return;
*xp++ = *ip;
goto *(&&base + *ip);
}

View File

@ -1563,7 +1563,14 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
&& POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (def_stmt))))
|| (is_gimple_assign (def_stmt)
&& gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR))
base = gimple_assign_rhs1 (def_stmt);
{
tree rhs1 = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (rhs1) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1))
break;
else
base = rhs1;
}
else
break;
}