Fix ice in set_value_range

Fix ice in set_value_range
gcc/ChangeLog:

2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR ipa/78121
	* ipa-cp.c (propagate_vr_accross_jump_function): Pass param type.
	Also fold constant passed as argument while computing value range.
	(propagate_constants_accross_call): Pass param type.
	* ipa-prop.c: export ipa_get_callee_param_type.
	* ipa-prop.h: export ipa_get_callee_param_type.

gcc/testsuite/ChangeLog:

2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR ipa/78121
	* gcc.dg/ipa/pr78121.c: New test.

From-SVN: r241989
This commit is contained in:
Kugan Vivekanandarajah 2016-11-09 01:41:26 +00:00 committed by Kugan Vivekanandarajah
parent 8f33501e32
commit 5d5f1e95b1
6 changed files with 48 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2016-11-09 Kugan Vivekanandarajah <kuganv@linaro.org>
PR ipa/78121
* ipa-cp.c (propagate_vr_accross_jump_function): Pass param type.
Also fold constant passed as argument while computing value range.
(propagate_constants_accross_call): Pass param type.
* ipa-prop.c: export ipa_get_callee_param_type.
* ipa-prop.h: export ipa_get_callee_param_type.
2016-11-09 Maxim Ostapenko <m.ostapenko@samsung.com>
* asan.h (asan_intercepted_p): Handle BUILT_IN_STRCSPN,

View File

@ -1834,12 +1834,14 @@ propagate_bits_accross_jump_function (cgraph_edge *cs, int idx, ipa_jump_func *j
}
/* Propagate value range across jump function JFUNC that is associated with
edge CS and update DEST_PLATS accordingly. */
edge CS with param of callee of PARAM_TYPE and update DEST_PLATS
accordingly. */
static bool
propagate_vr_accross_jump_function (cgraph_edge *cs,
ipa_jump_func *jfunc,
struct ipcp_param_lattices *dest_plats)
struct ipcp_param_lattices *dest_plats,
tree param_type)
{
struct ipcp_param_lattices *src_lats;
ipcp_vr_lattice *dest_lat = &dest_plats->m_value_range;
@ -1847,6 +1849,11 @@ propagate_vr_accross_jump_function (cgraph_edge *cs,
if (dest_lat->bottom_p ())
return false;
if (!param_type
|| (!INTEGRAL_TYPE_P (param_type)
&& !POINTER_TYPE_P (param_type)))
return dest_lat->set_to_bottom ();
if (jfunc->type == IPA_JF_PASS_THROUGH)
{
struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
@ -1865,6 +1872,7 @@ propagate_vr_accross_jump_function (cgraph_edge *cs,
{
if (TREE_OVERFLOW_P (val))
val = drop_tree_overflow (val);
val = fold_convert (param_type, val);
jfunc->vr_known = true;
jfunc->m_vr.type = VR_RANGE;
jfunc->m_vr.min = val;
@ -2214,6 +2222,7 @@ propagate_constants_accross_call (struct cgraph_edge *cs)
{
struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);
struct ipcp_param_lattices *dest_plats;
tree param_type = ipa_get_callee_param_type (cs, i);
dest_plats = ipa_get_parm_lattices (callee_info, i);
if (availability == AVAIL_INTERPOSABLE)
@ -2230,7 +2239,8 @@ propagate_constants_accross_call (struct cgraph_edge *cs)
dest_plats);
if (opt_for_fn (callee->decl, flag_ipa_vrp))
ret |= propagate_vr_accross_jump_function (cs,
jump_func, dest_plats);
jump_func, dest_plats,
param_type);
else
ret |= dest_plats->m_value_range.set_to_bottom ();
}

View File

@ -1595,7 +1595,10 @@ determine_locally_known_aggregate_parts (gcall *call, tree arg,
}
}
static tree
/* Return the Ith param type of callee associated with call graph
edge E. */
tree
ipa_get_callee_param_type (struct cgraph_edge *e, int i)
{
int n;

View File

@ -818,6 +818,7 @@ ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
ipa_parm_adjustment_vec,
bool);
void ipa_release_body_info (struct ipa_func_body_info *);
tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
/* From tree-sra.c: */
tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree,

View File

@ -1,3 +1,8 @@
2016-11-09 Kugan Vivekanandarajah <kuganv@linaro.org>
PR ipa/78121
* gcc.dg/ipa/pr78121.c: New test.
2016-11-09 Maxim Ostapenko <m.ostapenko@samsung.com>
* c-c++-common/asan/default_options.h: New file.

View File

@ -0,0 +1,16 @@
/* PR ipa/78121 */
/* { dg-do compile } */
/* { dg-options "-ansi -O2 -fdump-ipa-cp-details" } */
void fn2 (unsigned char c);
int a;
static void fn1(c) unsigned char c;
{
if (a)
fn2 (c);
fn1('#');
}
void fn3() { fn1 (267); }
/* { dg-final { scan-ipa-dump-times "Setting value range of param 0 \\\[11, 35\\\]" 1 "cp" } } */