aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-07-23 15:37:23 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-07-23 15:37:23 -0700
commitab8907ef75b71c987932a299bddf04cb73907c69 (patch)
tree6fa3fcbf916c4e6bd0c3081ee4de2cf5ae950925 /gcc
parent5aa33bdb4f75939b9467a4580aa13bb6997f192c (diff)
downloadgcc-ab8907ef75b71c987932a299bddf04cb73907c69.zip
gcc-ab8907ef75b71c987932a299bddf04cb73907c69.tar.gz
gcc-ab8907ef75b71c987932a299bddf04cb73907c69.tar.bz2
expr.c (expand_expr_real_1): Don't handle non-local variables.
* expr.c (expand_expr_real_1): Don't handle non-local variables. * expr.h (fix_lexical_addr): Remove. * function.c (NEED_SEPARATE_AP): Remove. (fix_lexical_addr): Remove. * tree-alias-common.c (get_alias_var_decl): Check TREE_STATIC, not null decl_function_context. (create_alias_vars): Likewise. * tree-cfg.c (make_ctrl_stmt_edges): Don't check for non-local labels. (simple_goto_p): Likewise. * tree-dfa.c (add_referenced_var): Don't check for non-local variables. * tree-ssa-ccp.c (get_default_value): Likewise. * tree-tailcall.c (suitable_for_tail_opt_p): Likewise. * tree.c (needs_to_live_in_memory): Likewise. * tree-flow-inline.h (may_be_aliased): Move... * tree-ssa-alias.c (may_be_aliased): ... here. Enhance check for when TREE_STATIC variables may be addressable. From-SVN: r85099
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/expr.c34
-rw-r--r--gcc/expr.h4
-rw-r--r--gcc/function.c45
-rw-r--r--gcc/tree-alias-common.c8
-rw-r--r--gcc/tree-cfg.c11
-rw-r--r--gcc/tree-dfa.c5
-rw-r--r--gcc/tree-flow-inline.h8
-rw-r--r--gcc/tree-flow.h2
-rw-r--r--gcc/tree-ssa-alias.c31
-rw-r--r--gcc/tree-ssa-ccp.c3
-rw-r--r--gcc/tree-tailcall.c3
-rw-r--r--gcc/tree.c4
13 files changed, 66 insertions, 111 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 81a50a6..f14f45b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+2004-07-23 Richard Henderson <rth@redhat.com>
+
+ * expr.c (expand_expr_real_1): Don't handle non-local variables.
+ * expr.h (fix_lexical_addr): Remove.
+ * function.c (NEED_SEPARATE_AP): Remove.
+ (fix_lexical_addr): Remove.
+ * tree-alias-common.c (get_alias_var_decl): Check TREE_STATIC,
+ not null decl_function_context.
+ (create_alias_vars): Likewise.
+ * tree-cfg.c (make_ctrl_stmt_edges): Don't check for non-local labels.
+ (simple_goto_p): Likewise.
+ * tree-dfa.c (add_referenced_var): Don't check for non-local variables.
+ * tree-ssa-ccp.c (get_default_value): Likewise.
+ * tree-tailcall.c (suitable_for_tail_opt_p): Likewise.
+ * tree.c (needs_to_live_in_memory): Likewise.
+ * tree-flow-inline.h (may_be_aliased): Move...
+ * tree-ssa-alias.c (may_be_aliased): ... here. Enhance check for
+ when TREE_STATIC variables may be addressable.
+
2004-07-24 Jakub Jelinek <jakub@redhat.com>
* Makefile.in (site.exp): Add HOSTCC and HOSTCFLAGS to site.exp.
diff --git a/gcc/expr.c b/gcc/expr.c
index d8ab443..b3ef3ef 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6368,33 +6368,15 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
/* Show we haven't gotten RTL for this yet. */
temp = 0;
- /* Handle variables inherited from containing functions. */
+ /* Variables inherited from containing functions should have
+ been lowered by this point. */
context = decl_function_context (exp);
-
- if (context != 0 && context != current_function_decl
- /* If var is static, we don't need a static chain to access it. */
- && ! (MEM_P (DECL_RTL (exp))
- && CONSTANT_P (XEXP (DECL_RTL (exp), 0))))
- {
- rtx addr;
-
- /* Mark as non-local and addressable. */
- DECL_NONLOCAL (exp) = 1;
- if (DECL_NO_STATIC_CHAIN (current_function_decl))
- abort ();
- lang_hooks.mark_addressable (exp);
- if (!MEM_P (DECL_RTL (exp)))
- abort ();
- addr = XEXP (DECL_RTL (exp), 0);
- if (MEM_P (addr))
- addr
- = replace_equiv_address (addr,
- fix_lexical_addr (XEXP (addr, 0), exp));
- else
- addr = fix_lexical_addr (addr, exp);
-
- temp = replace_equiv_address (DECL_RTL (exp), addr);
- }
+ if (context != 0
+ && context != current_function_decl
+ && !TREE_STATIC (exp)
+ /* ??? C++ creates functions that are not TREE_STATIC. */
+ && TREE_CODE (exp) != FUNCTION_DECL)
+ abort ();
/* This is the case of an array whose size is to be determined
from its initializer, while the initializer is still being parsed.
diff --git a/gcc/expr.h b/gcc/expr.h
index d3fab31..0126c58 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -556,10 +556,6 @@ extern rtx expr_size (tree);
if the size can vary or is larger than an integer. */
extern HOST_WIDE_INT int_expr_size (tree);
-/* Convert a stack slot address ADDR valid in function FNDECL
- into an address valid in this function (using a static chain). */
-extern rtx fix_lexical_addr (rtx, tree);
-
/* Return the address of the trampoline for entering nested fn FUNCTION. */
extern rtx trampoline_address (tree);
diff --git a/gcc/function.c b/gcc/function.c
index 23fb74c..956fa76 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -87,16 +87,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
alignment. */
#define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
-/* NEED_SEPARATE_AP means that we cannot derive ap from the value of fp
- during rtl generation. If they are different register numbers, this is
- always true. It may also be true if
- FIRST_PARM_OFFSET - STARTING_FRAME_OFFSET is not a constant during rtl
- generation. See fix_lexical_addr for details. */
-
-#if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
-#define NEED_SEPARATE_AP
-#endif
-
/* Nonzero if function being compiled doesn't contain any calls
(ignoring the prologue and epilogue). This is set prior to
local register allocation and is valid for the remaining
@@ -3571,41 +3561,6 @@ setjmp_args_warning (void)
}
-/* Convert a stack slot address ADDR for variable VAR
- (from a containing function)
- into an address valid in this function (using a static chain). */
-
-rtx
-fix_lexical_addr (rtx addr, tree var)
-{
- rtx basereg;
- HOST_WIDE_INT displacement;
- tree context = decl_function_context (var);
- struct function *fp;
- rtx base = 0;
-
- /* If this is the present function, we need not do anything. */
- if (context == current_function_decl)
- return addr;
-
- fp = find_function_data (context);
-
- /* Decode given address as base reg plus displacement. */
- if (REG_P (addr))
- basereg = addr, displacement = 0;
- else if (GET_CODE (addr) == PLUS && GET_CODE (XEXP (addr, 1)) == CONST_INT)
- basereg = XEXP (addr, 0), displacement = INTVAL (XEXP (addr, 1));
- else
- abort ();
-
- if (base == 0)
- abort ();
-
- /* Use same offset, relative to appropriate static chain or argument
- pointer. */
- return plus_constant (base, displacement);
-}
-
/* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
and create duplicate blocks. */
/* ??? Need an option to either create block fragments or to create
diff --git a/gcc/tree-alias-common.c b/gcc/tree-alias-common.c
index a7ce22d..d1a8568 100644
--- a/gcc/tree-alias-common.c
+++ b/gcc/tree-alias-common.c
@@ -154,11 +154,7 @@ get_alias_var_decl (tree decl)
newvar = create_alias_var (decl);
/* Assign globals to global var for purposes of intraprocedural
analysis. */
- if ((DECL_CONTEXT (decl) == NULL
- || TREE_PUBLIC (decl)
- || TREE_STATIC (decl)
- || decl_function_context (decl) == NULL)
- && decl != pta_global_var)
+ if (TREE_STATIC (decl) && decl != pta_global_var)
{
current_alias_ops->addr_assign (current_alias_ops,
get_alias_var (pta_global_var),
@@ -1016,7 +1012,7 @@ create_alias_vars (void)
{
var = TREE_VALUE (vars);
if (TREE_CODE (var) != LABEL_DECL
- && decl_function_context (var) == NULL
+ && TREE_STATIC (var)
&& DECL_INITIAL (var))
find_func_aliases (var);
}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 1c04e52..c9d2424 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -459,17 +459,12 @@ static void
make_ctrl_stmt_edges (basic_block bb)
{
tree last = last_stmt (bb);
- tree first = first_stmt (bb);
#if defined ENABLE_CHECKING
if (last == NULL_TREE)
abort();
#endif
- if (TREE_CODE (first) == LABEL_EXPR
- && DECL_NONLOCAL (LABEL_EXPR_LABEL (first)))
- make_edge (ENTRY_BLOCK_PTR, bb, EDGE_ABNORMAL);
-
switch (TREE_CODE (last))
{
case GOTO_EXPR:
@@ -2541,10 +2536,8 @@ computed_goto_p (tree t)
bool
simple_goto_p (tree expr)
{
- return (TREE_CODE (expr) == GOTO_EXPR
- && TREE_CODE (GOTO_DESTINATION (expr)) == LABEL_DECL
- && (decl_function_context (GOTO_DESTINATION (expr))
- == current_function_decl));
+ return (TREE_CODE (expr) == GOTO_EXPR
+ && TREE_CODE (GOTO_DESTINATION (expr)) == LABEL_DECL);
}
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 91d7ecd..c8986e8 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -903,11 +903,6 @@ add_referenced_var (tree var, struct walk_state *walk_state)
/* Global and static variables are call-clobbered, always. */
if (needs_to_live_in_memory (var))
mark_call_clobbered (var);
-
- /* DECL_NONLOCAL variables should not be removed, as they are needed
- to emit nested functions. */
- if (DECL_NONLOCAL (var))
- v_ann->used = 1;
}
}
diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h
index d48f205..97d56d8 100644
--- a/gcc/tree-flow-inline.h
+++ b/gcc/tree-flow-inline.h
@@ -635,14 +635,6 @@ loop_containing_stmt (tree stmt)
return bb->loop_father;
}
-/* Return true if VAR may be aliased. */
-static inline bool
-may_be_aliased (tree var)
-{
- return (TREE_ADDRESSABLE (var)
- || decl_function_context (var) != current_function_decl);
-}
-
/* Return true if VAR is a clobbered by function calls. */
static inline bool
is_call_clobbered (tree var)
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index dcde389..600d462 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -325,7 +325,6 @@ static inline tree immediate_use (dataflow_t, int);
static inline dataflow_t get_immediate_uses (tree);
static inline void set_default_def (tree, tree);
static inline tree default_def (tree);
-static inline bool may_be_aliased (tree);
/*---------------------------------------------------------------------------
Structure representing predictions in tree level.
@@ -554,6 +553,7 @@ extern void dump_points_to_info (FILE *);
extern void debug_points_to_info (void);
extern void dump_points_to_info_for (FILE *, tree);
extern void debug_points_to_info_for (tree);
+extern bool may_be_aliased (tree);
/* Call-back function for walk_use_def_chains(). At each reaching
definition, a function with this prototype is called. */
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index bf11fe2..a854b0b 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2473,3 +2473,34 @@ debug_may_aliases_for (tree var)
{
dump_may_aliases_for (stderr, var);
}
+
+/* Return true if VAR may be aliased. */
+
+bool
+may_be_aliased (tree var)
+{
+ /* Obviously. */
+ if (TREE_ADDRESSABLE (var))
+ return true;
+
+ /* Automatic variables can't have their addresses escape any other way. */
+ if (!TREE_STATIC (var))
+ return false;
+
+ /* Globally visible variables can have their addresses taken by other
+ translation units. */
+ if (DECL_EXTERNAL (var) || TREE_PUBLIC (var))
+ return true;
+
+ /* If we're in unit-at-a-time mode, then we must have seen all occurrences
+ of address-of operators, and so we can trust TREE_ADDRESSABLE. Otherwise
+ we can only be sure the variable isn't addressable if it's local to the
+ current function. */
+ if (flag_unit_at_a_time)
+ return false;
+ if (decl_function_context (var) == current_function_decl)
+ return false;
+
+ return true;
+}
+
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 38bd64a..04ab19d 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2390,8 +2390,7 @@ get_default_value (tree var)
/* Function arguments and volatile variables are considered VARYING. */
val.lattice_val = VARYING;
}
- else if (decl_function_context (sym) != current_function_decl
- || TREE_STATIC (sym))
+ else if (TREE_STATIC (sym))
{
/* Globals and static variables are considered UNKNOWN_VAL,
unless they are declared 'const'. */
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 5a89868..d3d48f5 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -143,8 +143,7 @@ suitable_for_tail_opt_p (void)
{
tree var = VARRAY_TREE (referenced_vars, i);
- if (decl_function_context (var) == current_function_decl
- && !TREE_STATIC (var)
+ if (!TREE_STATIC (var)
&& var_ann (var)->mem_tag_kind == NOT_A_TAG
&& is_call_clobbered (var))
return false;
diff --git a/gcc/tree.c b/gcc/tree.c
index 4ed3b67..bcb8dff 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5671,10 +5671,8 @@ needs_to_live_in_memory (tree t)
return (DECL_NEEDS_TO_LIVE_IN_MEMORY_INTERNAL (t)
|| TREE_STATIC (t)
|| DECL_EXTERNAL (t)
- || DECL_NONLOCAL (t)
|| (TREE_CODE (t) == RESULT_DECL
- && aggregate_value_p (t, current_function_decl))
- || decl_function_context (t) != current_function_decl);
+ && aggregate_value_p (t, current_function_decl)));
}
/* There are situations in which a language considers record types