This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
gcj: remove aliases for local variables
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Wed, 21 Jun 2006 15:20:41 +0100
- Subject: gcj: remove aliases for local variables
The bytecode front-end of gcj has long produced worse debug
information than the source front-end, partly due to the problem of
representing debug information for local variables.
At the present time we use a single canonical variable for each slot
in the VM and copying updates into named debug variables. Andrew
Pinksi pointed out that we don't need to keep local copies of
variables for the purpose of debugging information: a DECL_VALUE_EXPR
serves the purpose just as well.
This reduces the volume of trees produced by the gcj front-end,
increases compilation speed, and improves the accuracy of the
debugging information.
Andrew.
2006-06-21 Andrew Haley <aph@redhat.com>
* java-tree.h (update_aliases): Remove
* expr.c (expand_iinc): Remove call to update_aliases().
(STORE_INTERNAL): Likewise.
* decl.c (update_aliases, initialize_local_variable)
(maybe_pushlevels): Set DECL_VALUE_EXPR for debugging decls.
Index: java/decl.c
===================================================================
--- java/decl.c (revision 114772)
+++ java/decl.c (working copy)
@@ -160,46 +160,6 @@
return true;
}
-/* Copy the value in decl into every live alias in the same local
- variable slot. Some of these will be dead stores removed by the
- optimizer. */
-
-void
-update_aliases (tree decl, int index, int pc)
-{
- tree decl_type = TREE_TYPE (decl);
- tree tmp;
-
- gcc_assert (! debug_variable_p (decl));
-
- for (tmp = TREE_VEC_ELT (decl_map, index);
- tmp != NULL_TREE;
- tmp = DECL_LOCAL_SLOT_CHAIN (tmp))
- {
- tree tmp_type = TREE_TYPE (tmp);
- if (tmp != decl
- && LOCAL_SLOT_P (tmp) == 0
- && (pc == -1
- || (pc >= DECL_LOCAL_START_PC (tmp)
- && pc < DECL_LOCAL_END_PC (tmp)))
- /* This test is < (rather than <=) because there's no point
- updating an alias that's about to die at the end of this
- instruction. */
- && (tmp_type == decl_type
- || (INTEGRAL_TYPE_P (tmp_type)
- && INTEGRAL_TYPE_P (decl_type)
- && TYPE_PRECISION (decl_type) <= 32
- && TYPE_PRECISION (tmp_type) <= 32)
- || (TREE_CODE (tmp_type) == POINTER_TYPE
- && TREE_CODE (decl_type) == POINTER_TYPE)))
- {
- tree src = build1 (NOP_EXPR, tmp_type, decl);
- gcc_assert (! LOCAL_VAR_OUT_OF_SCOPE_P (tmp));
- java_add_stmt (build2 (MODIFY_EXPR, tmp_type, tmp, src));
- }
- }
-}
-
static tree
push_jvm_slot (int index, tree decl)
{
@@ -220,52 +180,6 @@
return decl;
}
-/* At the point of its creation a local variable decl inherits
- whatever is already in the same slot. In the case of a local
- variable that is declared but unused, we won't find anything. */
-
-static void
-initialize_local_variable (tree decl, int index)
-{
- tree decl_type = TREE_TYPE (decl);
- if (TREE_CODE (decl_type) == POINTER_TYPE)
- {
- tree tmp = TREE_VEC_ELT (base_decl_map, index);
-
- if (tmp)
- {
- /* At the point of its creation this decl inherits whatever
- is in the slot. */
- tree src = build1 (NOP_EXPR, decl_type, tmp);
- java_add_stmt (build2 (MODIFY_EXPR, decl_type, decl, src));
- }
- }
- else
- {
- tree tmp;
-
- for (tmp = TREE_VEC_ELT (decl_map, index);
- tmp != NULL_TREE;
- tmp = DECL_LOCAL_SLOT_CHAIN (tmp))
- {
- tree tmp_type = TREE_TYPE (tmp);
- if (tmp != decl
- && ! debug_variable_p (tmp)
- && (tmp_type == decl_type
- || (INTEGRAL_TYPE_P (tmp_type)
- && INTEGRAL_TYPE_P (decl_type)
- && TYPE_PRECISION (decl_type) <= 32
- && TYPE_PRECISION (tmp_type) <= 32
- && TYPE_PRECISION (tmp_type)
- >= TYPE_PRECISION (decl_type))))
- {
- java_add_stmt (build2 (MODIFY_EXPR, decl_type, decl, tmp));
- return;
- }
- }
- }
-}
-
/* Find the best declaration based upon type. If 'decl' fits 'type' better
than 'best', return 'decl'. Otherwise return 'best'. */
@@ -1800,10 +1714,17 @@
current_binding_level->names = NULL;
for ( ; decl != NULL_TREE; decl = next)
{
+ int index = DECL_LOCAL_SLOT_NUMBER (decl);
+ tree base_decl;
next = TREE_CHAIN (decl);
- push_jvm_slot (DECL_LOCAL_SLOT_NUMBER (decl), decl);
+ push_jvm_slot (index, decl);
pushdecl (decl);
- initialize_local_variable (decl, DECL_LOCAL_SLOT_NUMBER (decl));
+ base_decl
+ = find_local_variable (index, TREE_TYPE (decl), pc);
+ if (TREE_CODE (TREE_TYPE (base_decl)) == POINTER_TYPE)
+ base_decl = TREE_VEC_ELT (base_decl_map, index);
+ SET_DECL_VALUE_EXPR (decl, base_decl);
+ DECL_HAS_VALUE_EXPR_P (decl) = 1;
}
}
Index: java/expr.c
===================================================================
--- java/expr.c (revision 114778)
+++ java/expr.c (working copy)
@@ -1451,7 +1451,6 @@
constant_value = build_int_cst (NULL_TREE, ival);
res = fold_build2 (PLUS_EXPR, int_type_node, local_var, constant_value);
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res));
- update_aliases (local_var, local_var_index, pc);
}
@@ -3413,7 +3412,6 @@
decl = find_local_variable (index, type, oldpc); \
set_local_type (index, type); \
java_add_stmt (build2 (MODIFY_EXPR, type, decl, value)); \
- update_aliases (decl, index, PC); \
}
#define STORE(OPERAND_TYPE, OPERAND_VALUE) \
Index: java/java-tree.h
===================================================================
--- java/java-tree.h (revision 114778)
+++ java/java-tree.h (working copy)
@@ -1221,7 +1221,6 @@
extern tree build_static_field_ref (tree);
extern tree build_address_of (tree);
extern tree find_local_variable (int index, tree type, int pc);
-extern void update_aliases (tree decl, int index, int pc);
extern tree find_stack_slot (int index, tree type);
extern tree build_prim_array_type (tree, HOST_WIDE_INT);
extern tree build_java_array_type (tree, HOST_WIDE_INT);