Commit e38811ce by Richard Guenther Committed by Richard Biener

tree-ssa-structalias.c (find_func_aliases_for_builtin_call): New function split out from ...

2011-04-28  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
	New function split out from ...
	(find_func_aliases): ... here.  Call it.
	(find_func_aliases_for_call): Likewise.

From-SVN: r173060
parent a300121e
2011-04-28 Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
New function split out from ...
(find_func_aliases): ... here. Call it.
(find_func_aliases_for_call): Likewise.
2011-04-27 Gabriel Dos Reis <gdr@integrable-solutions.net>
* internal-fn.h (internal_fn_name_array): Declare.
......
......@@ -3959,58 +3959,17 @@ get_fi_for_callee (gimple call)
gcc_unreachable ();
}
/* Walk statement T setting up aliasing constraints according to the
references found in T. This function is the main part of the
constraint builder. AI points to auxiliary alias information used
when building alias sets and computing alias grouping heuristics. */
/* Create constraints for the builtin call T. Return true if the call
was handled, otherwise false. */
static void
find_func_aliases (gimple origt)
static bool
find_func_aliases_for_builtin_call (gimple t)
{
gimple t = origt;
tree fndecl = gimple_call_fndecl (t);
VEC(ce_s, heap) *lhsc = NULL;
VEC(ce_s, heap) *rhsc = NULL;
struct constraint_expr *c;
varinfo_t fi;
/* Now build constraints expressions. */
if (gimple_code (t) == GIMPLE_PHI)
{
size_t i;
unsigned int j;
/* For a phi node, assign all the arguments to
the result. */
get_constraint_for (gimple_phi_result (t), &lhsc);
for (i = 0; i < gimple_phi_num_args (t); i++)
{
tree strippedrhs = PHI_ARG_DEF (t, i);
STRIP_NOPS (strippedrhs);
get_constraint_for_rhs (gimple_phi_arg_def (t, i), &rhsc);
FOR_EACH_VEC_ELT (ce_s, lhsc, j, c)
{
struct constraint_expr *c2;
while (VEC_length (ce_s, rhsc) > 0)
{
c2 = VEC_last (ce_s, rhsc);
process_constraint (new_constraint (*c, *c2));
VEC_pop (ce_s, rhsc);
}
}
}
}
/* In IPA mode, we need to generate constraints to pass call
arguments through their calls. There are two cases,
either a GIMPLE_CALL returning a value, or just a plain
GIMPLE_CALL when we are not.
In non-ipa mode, we need to generate constraints for each
pointer passed by address. */
else if (is_gimple_call (t))
{
tree fndecl = gimple_call_fndecl (t);
if (fndecl != NULL_TREE
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
/* ??? All builtins that are handled here need to be handled
......@@ -4058,7 +4017,7 @@ find_func_aliases (gimple origt)
process_all_all_constraints (lhsc, rhsc);
VEC_free (ce_s, heap, lhsc);
VEC_free (ce_s, heap, rhsc);
return;
return true;
}
case BUILT_IN_MEMSET:
{
......@@ -4092,7 +4051,7 @@ find_func_aliases (gimple origt)
FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
process_constraint (new_constraint (*lhsp, ac));
VEC_free (ce_s, heap, lhsc);
return;
return true;
}
/* All the following functions do not return pointers, do not
modify the points-to sets of memory reachable from their
......@@ -4116,7 +4075,7 @@ find_func_aliases (gimple origt)
case BUILT_IN_REMQUOF:
case BUILT_IN_REMQUOL:
case BUILT_IN_FREE:
return;
return true;
/* Trampolines are special - they set up passing the static
frame. */
case BUILT_IN_INIT_TRAMPOLINE:
......@@ -4148,7 +4107,7 @@ find_func_aliases (gimple origt)
VEC_free (ce_s, heap, rhsc);
VEC_free (ce_s, heap, lhsc);
return;
return true;
}
}
/* Else fallthru to generic handling which will let
......@@ -4168,7 +4127,7 @@ find_func_aliases (gimple origt)
VEC_free (ce_s, heap, rhsc);
VEC_free (ce_s, heap, lhsc);
}
return;
return true;
}
/* Variadic argument handling needs to be handled in IPA
mode as well. */
......@@ -4192,13 +4151,13 @@ find_func_aliases (gimple origt)
VEC_free (ce_s, heap, lhsc);
/* va_list is clobbered. */
make_constraint_to (get_call_clobber_vi (t)->id, valist);
return;
return true;
}
break;
}
/* va_end doesn't have any effect that matters. */
case BUILT_IN_VA_END:
return;
return true;
/* Alternate return. Simply give up for now. */
case BUILT_IN_RETURN:
{
......@@ -4216,7 +4175,7 @@ find_func_aliases (gimple origt)
rhs.type = SCALAR;
process_constraint (new_constraint (lhs, rhs));
}
return;
return true;
}
/* printf-style functions may have hooks to set pointers to
point to somewhere into the generated string. Leave them
......@@ -4224,6 +4183,25 @@ find_func_aliases (gimple origt)
default:
/* Fallthru to general call handling. */;
}
return false;
}
/* Create constraints for the call T. */
static void
find_func_aliases_for_call (gimple t)
{
tree fndecl = gimple_call_fndecl (t);
VEC(ce_s, heap) *lhsc = NULL;
VEC(ce_s, heap) *rhsc = NULL;
varinfo_t fi;
if (fndecl != NULL_TREE
&& DECL_BUILT_IN (fndecl)
&& find_func_aliases_for_builtin_call (t))
return;
if (!in_ipa_mode
|| gimple_call_internal_p (t)
|| (fndecl
......@@ -4327,7 +4305,60 @@ find_func_aliases (gimple origt)
process_constraint (new_constraint (lhs, *rhsp));
}
}
}
/* Walk statement T setting up aliasing constraints according to the
references found in T. This function is the main part of the
constraint builder. AI points to auxiliary alias information used
when building alias sets and computing alias grouping heuristics. */
static void
find_func_aliases (gimple origt)
{
gimple t = origt;
VEC(ce_s, heap) *lhsc = NULL;
VEC(ce_s, heap) *rhsc = NULL;
struct constraint_expr *c;
varinfo_t fi;
/* Now build constraints expressions. */
if (gimple_code (t) == GIMPLE_PHI)
{
size_t i;
unsigned int j;
/* For a phi node, assign all the arguments to
the result. */
get_constraint_for (gimple_phi_result (t), &lhsc);
for (i = 0; i < gimple_phi_num_args (t); i++)
{
tree strippedrhs = PHI_ARG_DEF (t, i);
STRIP_NOPS (strippedrhs);
get_constraint_for_rhs (gimple_phi_arg_def (t, i), &rhsc);
FOR_EACH_VEC_ELT (ce_s, lhsc, j, c)
{
struct constraint_expr *c2;
while (VEC_length (ce_s, rhsc) > 0)
{
c2 = VEC_last (ce_s, rhsc);
process_constraint (new_constraint (*c, *c2));
VEC_pop (ce_s, rhsc);
}
}
}
}
/* In IPA mode, we need to generate constraints to pass call
arguments through their calls. There are two cases,
either a GIMPLE_CALL returning a value, or just a plain
GIMPLE_CALL when we are not.
In non-ipa mode, we need to generate constraints for each
pointer passed by address. */
else if (is_gimple_call (t))
find_func_aliases_for_call (t);
/* Otherwise, just a regular assignment statement. Only care about
operations with pointer result, others are dealt with as escape
points if they have pointer operands. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment