Skip to content

Commit

Permalink
2009-06-16 Richard Guenther <[email protected]>
Browse files Browse the repository at this point in the history
	* tree-ssa-alias.c (is_escape_site): Remove.
	* tree-ssa-alias.h (enum escape_type): Remove.
	(is_escape_site): Likewise.
	* tree-ssa-structalias.c (find_func_aliases): Handle escapes
	via casts and asms without deferring to is_escape_site.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148534 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
rguenth committed Jun 16, 2009
1 parent 60a132a commit e8146f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 105 deletions.
8 changes: 8 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2009-06-16 Richard Guenther <[email protected]>

* tree-ssa-alias.c (is_escape_site): Remove.
* tree-ssa-alias.h (enum escape_type): Remove.
(is_escape_site): Likewise.
* tree-ssa-structalias.c (find_func_aliases): Handle escapes
via casts and asms without deferring to is_escape_site.

2009-06-16 Jakub Jelinek <[email protected]>

PR middle-end/40446
Expand Down
76 changes: 0 additions & 76 deletions gcc/tree-ssa-alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,82 +232,6 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
return pt_solutions_intersect (&pi1->pt, &pi2->pt);
}

/* Return true if STMT is an "escape" site from the current function. Escape
sites those statements which might expose the address of a variable
outside the current function. STMT is an escape site iff:
1- STMT is a function call, or
2- STMT is an __asm__ expression, or
3- STMT is an assignment to a non-local variable, or
4- STMT is a return statement.
Return the type of escape site found, if we found one, or NO_ESCAPE
if none. */

enum escape_type
is_escape_site (gimple stmt)
{
if (is_gimple_call (stmt))
{
if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
return ESCAPE_TO_PURE_CONST;

return ESCAPE_TO_CALL;
}
else if (gimple_code (stmt) == GIMPLE_ASM)
return ESCAPE_TO_ASM;
else if (is_gimple_assign (stmt))
{
tree lhs = gimple_assign_lhs (stmt);

/* Get to the base of _REF nodes. */
if (TREE_CODE (lhs) != SSA_NAME)
lhs = get_base_address (lhs);

/* If we couldn't recognize the LHS of the assignment, assume that it
is a non-local store. */
if (lhs == NULL_TREE)
return ESCAPE_UNKNOWN;

if (gimple_assign_cast_p (stmt))
{
tree from = TREE_TYPE (gimple_assign_rhs1 (stmt));
tree to = TREE_TYPE (lhs);

/* If the RHS is a conversion between a pointer and an integer, the
pointer escapes since we can't track the integer. */
if (POINTER_TYPE_P (from) && !POINTER_TYPE_P (to))
return ESCAPE_BAD_CAST;
}

/* If the LHS is an SSA name, it can't possibly represent a non-local
memory store. */
if (TREE_CODE (lhs) == SSA_NAME)
return NO_ESCAPE;

/* If the LHS is a non-global decl, it isn't a non-local memory store.
If the LHS escapes, the RHS escape is dealt with in the PTA solver. */
if (DECL_P (lhs)
&& !is_global_var (lhs))
return NO_ESCAPE;

/* FIXME: LHS is not an SSA_NAME. Even if it's an assignment to a
local variables we cannot be sure if it will escape, because we
don't have information about objects not in SSA form. Need to
implement something along the lines of
J.-D. Choi, M. Gupta, M. J. Serrano, V. C. Sreedhar, and S. P.
Midkiff, ``Escape analysis for java,'' in Proceedings of the
Conference on Object-Oriented Programming Systems, Languages, and
Applications (OOPSLA), pp. 1-19, 1999. */
return ESCAPE_STORED_IN_GLOBAL;
}
else if (gimple_code (stmt) == GIMPLE_RETURN)
return ESCAPE_TO_RETURN;

return NO_ESCAPE;
}


/* Dump alias information on FILE. */

Expand Down
21 changes: 0 additions & 21 deletions gcc/tree-ssa-alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@
#include "coretypes.h"


/* The reasons a variable may escape a function. */
enum escape_type
{
NO_ESCAPE = 0, /* Doesn't escape. */
ESCAPE_STORED_IN_GLOBAL = 1 << 0,
ESCAPE_TO_ASM = 1 << 1, /* Passed by address to an assembly
statement. */
ESCAPE_TO_CALL = 1 << 2, /* Escapes to a function call. */
ESCAPE_BAD_CAST = 1 << 3, /* Cast from pointer to integer */
ESCAPE_TO_RETURN = 1 << 4, /* Returned from function. */
ESCAPE_TO_PURE_CONST = 1 << 5, /* Escapes to a pure or constant
function call. */
ESCAPE_IS_GLOBAL = 1 << 6, /* Is a global variable. */
ESCAPE_IS_PARM = 1 << 7, /* Is an incoming function argument. */
ESCAPE_UNKNOWN = 1 << 8 /* We believe it escapes for
some reason not enumerated
above. */
};


/* The points-to solution.
The points-to solution is a union of pt_vars and the abstract
Expand Down Expand Up @@ -107,7 +87,6 @@ typedef struct ao_ref_s
extern void ao_ref_init (ao_ref *, tree);
extern tree ao_ref_base (ao_ref *);
extern alias_set_type ao_ref_alias_set (ao_ref *);
extern enum escape_type is_escape_site (gimple);
extern bool ptr_deref_may_alias_global_p (tree);
extern bool refs_may_alias_p (tree, tree);
extern bool refs_anti_dependent_p (tree, tree);
Expand Down
14 changes: 6 additions & 8 deletions gcc/tree-ssa-structalias.c
Original file line number Diff line number Diff line change
Expand Up @@ -3561,7 +3561,6 @@ find_func_aliases (gimple origt)
VEC(ce_s, heap) *lhsc = NULL;
VEC(ce_s, heap) *rhsc = NULL;
struct constraint_expr *c;
enum escape_type stmt_escape_type;

/* Now build constraints expressions. */
if (gimple_code (t) == GIMPLE_PHI)
Expand Down Expand Up @@ -3759,16 +3758,15 @@ find_func_aliases (gimple origt)
&& is_global_var (lhsop))
make_escape_constraint (rhsop);
}

stmt_escape_type = is_escape_site (t);
if (stmt_escape_type == ESCAPE_BAD_CAST)
/* For conversions of pointers to non-pointers the pointer escapes. */
else if (gimple_assign_cast_p (t)
&& POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (t)))
&& !POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (t))))
{
gcc_assert (is_gimple_assign (t));
gcc_assert (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (t))
|| gimple_assign_rhs_code (t) == VIEW_CONVERT_EXPR);
make_escape_constraint (gimple_assign_rhs1 (t));
}
else if (stmt_escape_type == ESCAPE_TO_ASM)
/* Handle asms conservatively by adding escape constraints to everything. */
else if (gimple_code (t) == GIMPLE_ASM)
{
unsigned i, noutputs;
const char **oconstraints;
Expand Down

0 comments on commit e8146f0

Please sign in to comment.