This commit is contained in:
Jakub Jelinek 2009-09-08 11:05:43 +00:00
parent 1e5093a776
commit 116cffef39
11 changed files with 518 additions and 1327 deletions

View File

@ -1,2 +1,2 @@
fastjar-0.97.tar.gz
gcc-4.4.1-20090903.tar.bz2
gcc-4.4.1-20090908.tar.bz2

View File

@ -1,9 +1,9 @@
%global DATE 20090903
%global SVNREV 151396
%global DATE 20090908
%global SVNREV 151505
%global gcc_version 4.4.1
# Note, gcc_release must be integer, if you want to add suffixes to
# %{release}, append them after %{gcc_release} on Release: line.
%global gcc_release 9
%global gcc_release 10
%global _unpackaged_files_terminate_build 0
%global multilib_64_archs sparc64 ppc64 s390x x86_64
%global include_gappletviewer 1
@ -70,6 +70,8 @@ BuildRequires: binutils >= 2.19.51.0.14
# -static is used several times.
BuildRequires: glibc-static
BuildRequires: zlib-devel, gettext, dejagnu, bison, flex, texinfo, sharutils
# For VTA guality testing
BuildRequires: gdb
%if %{build_java}
BuildRequires: /usr/share/java/eclipse-ecj.jar, zip, unzip
%if %{bootstrap_java}
@ -157,8 +159,12 @@ Patch15: gcc44-raw-string.patch
Patch16: gcc44-unwind-debug-hook.patch
Patch17: gcc44-pr38757.patch
Patch18: gcc44-libstdc++-docs.patch
Patch19: gcc44-rh503816-1.patch
Patch20: gcc44-rh503816-2.patch
Patch19: gcc44-vta-cfgexpand-ptr-mode-pr41248.patch
Patch20: gcc44-vta-cselib-subreg-of-value-pr41276.patch
Patch21: gcc44-vta-loop-ivopts-propagate-on-release.patch
Patch22: gcc44-vta-no-g-with-gtoggle.patch
Patch23: gcc44-vta-phiopt-pr41232.patch
Patch24: gcc44-vta-ssa-update-former-vops-pr41229.patch
Patch1000: fastjar-0.97-segfault.patch
@ -464,8 +470,12 @@ which are required to compile with the GNAT.
%if %{build_libstdcxx_docs}
%patch18 -p0 -b .libstdc++-docs~
%endif
%patch19 -p0 -b .rh503816-1~
%patch20 -p0 -b .rh503816-2~
%patch19 -p0 -b .vta-cfgexpand-ptr-mode-pr41248~
%patch20 -p0 -b .vta-cselib-subreg-of-value-pr41276~
%patch21 -p0 -b .vta-loop-ivopts-propagate-on-release~
%patch22 -p0 -b .vta-no-g-with-gtoggle~
%patch23 -p0 -b .vta-phiopt-pr41232~
%patch24 -p0 -b .vta-ssa-update-former-vops-pr41229~
# This testcase doesn't compile.
rm libjava/testsuite/libjava.lang/PR35020*
@ -1805,6 +1815,13 @@ fi
%doc rpm.doc/changelogs/libmudflap/ChangeLog*
%changelog
* Tue Sep 8 2009 Jakub Jelinek <jakub@redhat.com> 4.4.1-10
- update from gcc-4_4-branch
- PRs fortran/41258, rtl-optimization/40861
- fix scheduler not to reorder potentially trapping insns across
calls that might not always return (#520916, PR rtl-optimization/41239)
- merge in VTA
* Thu Sep 3 2009 Jakub Jelinek <jakub@redhat.com> 4.4.1-9
- update from gcc-4_4-branch
- fix wide char constant stringification

View File

@ -1,827 +0,0 @@
2009-06-21 Jakub Jelinek <jakub@redhat.com>
* var-tracking.c (struct shared_hash_def, shared_hash): New types.
(dataflow_set): Change vars type from htab_t to shared_hash.
(shared_hash_pool, empty_shared_hash): New variables.
(vars_clear): Removed.
(shared_hash_shared, shared_hash_htab, shared_hash_copy,
shared_hash_find_slot_unshare, shared_hash_find_slot,
shared_hash_find_slot_noinsert, shared_hash_find): New
static inlines.
(shared_hash_unshare, shared_hash_destroy): New functions.
(unshare_variable): Unshare set->vars if shared, use
shared_hash_htab.
(vars_copy): Use htab_traverse_noresize instead of htab_traverse.
(get_init_value, find_src_set_src, dump_dataflow_set,
clobber_variable_part, emit_notes_for_differences): Use
shared_hash_htab.
(dataflow_set_init): Remove second argument, set vars to
empty_shared_hash instead of creating a new htab.
(dataflow_set_clear): Call shared_hash_destroy and set vars
to empty_shared_hash instead of calling vars_clear.
(dataflow_set_copy): Don't call vars_copy, instead just share
the src htab with dst.
(variable_union): Use shared_hash_*, use initially NO_INSERT
lookup if set->vars is shared. Don't keep slot cleared before
calling unshare_variable. Unshare set->vars if needed.
Even ->refcount == 1 vars must be unshared if set->vars is shared
and var needs to be modified.
(variable_canonicalize): New function.
(dataflow_set_union): If dst->vars is empty, just share src->vars
with dst->vars and traverse with variable_canonicalize to canonicalize
and unshare what is needed.
(dataflow_set_different): If old_set and new_set use the same shared
htab, they aren't different. If number of htab elements is different,
htabs are different. Use shared_hash_*.
(dataflow_set_destroy): Call shared_hash_destroy instead of
htab_delete.
(compute_bb_dataflow, emit_notes_in_bb, vt_emit_notes): Don't pass
second argument to dataflow_set_init.
(vt_initialize): Likewise. Initialize shared_hash_pool and
empty_shared_hash, move bb in/out initialization afterwards.
Use variable_htab_free instead of NULL as changed_variables del hook.
(variable_was_changed): Change type of second argument to pointer to
dataflow_set. When inserting var into changed_variables, bump
refcount. Unshare set->vars if set is shared htab and slot needs to
be cleared.
(set_variable_part): Use shared_hash_*, use initially NO_INSERT
lookup if set->vars is shared. Unshare set->vars if needed.
Even ->refcount == 1 vars must be unshared if set->vars is shared
and var needs to be modified. Adjust variable_was_changed caller.
(delete_variable_part): Use shared_hash_*. Even ->refcount == 1
vars must be unshared if set->vars is shared and var needs to be
modified. Adjust variable_was_changed caller.
(emit_note_insn_var_location): Don't pool_free var.
(emit_notes_for_differences_1): Initialize empty_var->refcount to 0
instead of 1.
(vt_finalize): Call htab_delete on empty_shared_hash->htab and
free_alloc_pool on shared_hash_pool.
* hashtab.c (htab_traverse): Don't call htab_expand for
nearly empty hashtabs with sizes 7, 13 or 31.
--- gcc/var-tracking.c (revision 148758)
+++ gcc/var-tracking.c (revision 148760)
@@ -182,6 +182,17 @@ typedef struct attrs_def
HOST_WIDE_INT offset;
} *attrs;
+/* Structure holding a refcounted hash table. If refcount > 1,
+ it must be first unshared before modified. */
+typedef struct shared_hash_def
+{
+ /* Reference count. */
+ int refcount;
+
+ /* Actual hash table. */
+ htab_t htab;
+} *shared_hash;
+
/* Structure holding the IN or OUT set for a basic block. */
typedef struct dataflow_set_def
{
@@ -192,7 +203,7 @@ typedef struct dataflow_set_def
attrs regs[FIRST_PSEUDO_REGISTER];
/* Variable locations. */
- htab_t vars;
+ shared_hash vars;
} dataflow_set;
/* The structure (one for each basic block) containing the information
@@ -280,12 +291,18 @@ static alloc_pool var_pool;
/* Alloc pool for struct location_chain_def. */
static alloc_pool loc_chain_pool;
+/* Alloc pool for struct shared_hash_def. */
+static alloc_pool shared_hash_pool;
+
/* Changed variables, notes will be emitted for them. */
static htab_t changed_variables;
/* Shall notes be emitted? */
static bool emit_notes;
+/* Empty shared hashtable. */
+static shared_hash empty_shared_hash;
+
/* Local function prototypes. */
static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
HOST_WIDE_INT *);
@@ -305,7 +322,6 @@ static void attrs_list_insert (attrs *,
static void attrs_list_copy (attrs *, attrs);
static void attrs_list_union (attrs *, attrs);
-static void vars_clear (htab_t);
static variable unshare_variable (dataflow_set *set, variable var,
enum var_init_status);
static int vars_copy_1 (void **, void *);
@@ -321,11 +337,12 @@ static void var_mem_delete_and_set (data
enum var_init_status, rtx);
static void var_mem_delete (dataflow_set *, rtx, bool);
-static void dataflow_set_init (dataflow_set *, int);
+static void dataflow_set_init (dataflow_set *);
static void dataflow_set_clear (dataflow_set *);
static void dataflow_set_copy (dataflow_set *, dataflow_set *);
static int variable_union_info_cmp_pos (const void *, const void *);
static int variable_union (void **, void *);
+static int variable_canonicalize (void **, void *);
static void dataflow_set_union (dataflow_set *, dataflow_set *);
static bool variable_part_different_p (variable_part *, variable_part *);
static bool variable_different_p (variable, variable, bool);
@@ -352,7 +369,7 @@ static void dump_vars (htab_t);
static void dump_dataflow_set (dataflow_set *);
static void dump_dataflow_sets (void);
-static void variable_was_changed (variable, htab_t);
+static void variable_was_changed (variable, dataflow_set *);
static void set_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT,
enum var_init_status, rtx);
static void clobber_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT,
@@ -742,12 +759,107 @@ attrs_list_union (attrs *dstp, attrs src
}
}
-/* Delete all variables from hash table VARS. */
+/* Shared hashtable support. */
+
+/* Return true if VARS is shared. */
+
+static inline bool
+shared_hash_shared (shared_hash vars)
+{
+ return vars->refcount > 1;
+}
+
+/* Return the hash table for VARS. */
+
+static inline htab_t
+shared_hash_htab (shared_hash vars)
+{
+ return vars->htab;
+}
+
+/* Copy variables into a new hash table. */
+
+static shared_hash
+shared_hash_unshare (shared_hash vars)
+{
+ shared_hash new_vars = (shared_hash) pool_alloc (shared_hash_pool);
+ gcc_assert (vars->refcount > 1);
+ new_vars->refcount = 1;
+ new_vars->htab
+ = htab_create (htab_elements (vars->htab) + 3, variable_htab_hash,
+ variable_htab_eq, variable_htab_free);
+ vars_copy (new_vars->htab, vars->htab);
+ vars->refcount--;
+ return new_vars;
+}
+
+/* Increment reference counter on VARS and return it. */
+
+static inline shared_hash
+shared_hash_copy (shared_hash vars)
+{
+ vars->refcount++;
+ return vars;
+}
+
+/* Decrement reference counter and destroy hash table if not shared
+ anymore. */
static void
-vars_clear (htab_t vars)
+shared_hash_destroy (shared_hash vars)
{
- htab_empty (vars);
+ gcc_assert (vars->refcount > 0);
+ if (--vars->refcount == 0)
+ {
+ htab_delete (vars->htab);
+ pool_free (shared_hash_pool, vars);
+ }
+}
+
+/* Unshare *PVARS if shared and return slot for DECL. If INS is
+ INSERT, insert it if not already present. */
+
+static inline void **
+shared_hash_find_slot_unshare (shared_hash *pvars, tree decl,
+ enum insert_option ins)
+{
+ if (shared_hash_shared (*pvars))
+ *pvars = shared_hash_unshare (*pvars);
+ return htab_find_slot_with_hash (shared_hash_htab (*pvars), decl,
+ VARIABLE_HASH_VAL (decl), ins);
+}
+
+/* Return slot for DECL, if it is already present in the hash table.
+ If it is not present, insert it only VARS is not shared, otherwise
+ return NULL. */
+
+static inline void **
+shared_hash_find_slot (shared_hash vars, tree decl)
+{
+ return htab_find_slot_with_hash (shared_hash_htab (vars), decl,
+ VARIABLE_HASH_VAL (decl),
+ shared_hash_shared (vars)
+ ? NO_INSERT : INSERT);
+}
+
+/* Return slot for DECL only if it is already present in the hash table. */
+
+static inline void **
+shared_hash_find_slot_noinsert (shared_hash vars, tree decl)
+{
+ return htab_find_slot_with_hash (shared_hash_htab (vars), decl,
+ VARIABLE_HASH_VAL (decl), NO_INSERT);
+}
+
+/* Return variable for DECL or NULL if not already present in the hash
+ table. */
+
+static inline variable
+shared_hash_find (shared_hash vars, tree decl)
+{
+ return (variable)
+ htab_find_with_hash (shared_hash_htab (vars), decl,
+ VARIABLE_HASH_VAL (decl));
}
/* Return a copy of a variable VAR and insert it to dataflow set SET. */
@@ -801,9 +913,7 @@ unshare_variable (dataflow_set *set, var
new_var->var_part[i].cur_loc = NULL;
}
- slot = htab_find_slot_with_hash (set->vars, new_var->decl,
- VARIABLE_HASH_VAL (new_var->decl),
- INSERT);
+ slot = shared_hash_find_slot_unshare (&set->vars, new_var->decl, INSERT);
*slot = new_var;
return new_var;
}
@@ -834,8 +944,7 @@ vars_copy_1 (void **slot, void *data)
static void
vars_copy (htab_t dst, htab_t src)
{
- vars_clear (dst);
- htab_traverse (src, vars_copy_1, dst);
+ htab_traverse_noresize (src, vars_copy_1, dst);
}
/* Map a decl to its main debug decl. */
@@ -874,7 +983,6 @@ var_reg_set (dataflow_set *set, rtx loc,
static int
get_init_value (dataflow_set *set, rtx loc, tree decl)
{
- void **slot;
variable var;
int i;
int ret_val = VAR_INIT_STATUS_UNKNOWN;
@@ -882,11 +990,9 @@ get_init_value (dataflow_set *set, rtx l
if (! flag_var_tracking_uninit)
return VAR_INIT_STATUS_INITIALIZED;
- slot = htab_find_slot_with_hash (set->vars, decl, VARIABLE_HASH_VAL (decl),
- NO_INSERT);
- if (slot)
+ var = shared_hash_find (set->vars, decl);
+ if (var)
{
- var = * (variable *) slot;
for (i = 0; i < var->n_var_parts && ret_val == VAR_INIT_STATUS_UNKNOWN; i++)
{
location_chain nextp;
@@ -1050,11 +1156,10 @@ var_mem_delete (dataflow_set *set, rtx l
VARS_SIZE is the initial size of hash table VARS. */
static void
-dataflow_set_init (dataflow_set *set, int vars_size)
+dataflow_set_init (dataflow_set *set)
{
init_attrs_list_set (set->regs);
- set->vars = htab_create (vars_size, variable_htab_hash, variable_htab_eq,
- variable_htab_free);
+ set->vars = shared_hash_copy (empty_shared_hash);
set->stack_adjust = 0;
}
@@ -1068,7 +1173,8 @@ dataflow_set_clear (dataflow_set *set)
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
attrs_list_clear (&set->regs[i]);
- vars_clear (set->vars);
+ shared_hash_destroy (set->vars);
+ set->vars = shared_hash_copy (empty_shared_hash);
}
/* Copy the contents of dataflow set SRC to DST. */
@@ -1081,7 +1187,8 @@ dataflow_set_copy (dataflow_set *dst, da
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
attrs_list_copy (&dst->regs[i], src->regs[i]);
- vars_copy (dst->vars, src->vars);
+ shared_hash_destroy (dst->vars);
+ dst->vars = shared_hash_copy (src->vars);
dst->stack_adjust = src->stack_adjust;
}
@@ -1129,15 +1236,14 @@ variable_union_info_cmp_pos (const void
static int
variable_union (void **slot, void *data)
{
- variable src, dst, *dstp;
+ variable src, dst;
+ void **dstp;
dataflow_set *set = (dataflow_set *) data;
int i, j, k;
src = *(variable *) slot;
- dstp = (variable *) htab_find_slot_with_hash (set->vars, src->decl,
- VARIABLE_HASH_VAL (src->decl),
- INSERT);
- if (!*dstp)
+ dstp = shared_hash_find_slot (set->vars, src->decl);
+ if (!dstp || !*dstp)
{
src->refcount++;
@@ -1162,16 +1268,23 @@ variable_union (void **slot, void *data)
if (! flag_var_tracking_uninit)
status = VAR_INIT_STATUS_INITIALIZED;
+ if (dstp)
+ *dstp = (void *) src;
unshare_variable (set, src, status);
}
else
- *dstp = src;
+ {
+ if (!dstp)
+ dstp = shared_hash_find_slot_unshare (&set->vars, src->decl,
+ INSERT);
+ *dstp = (void *) src;
+ }
/* Continue traversing the hash table. */
return 1;
}
else
- dst = *dstp;
+ dst = (variable) *dstp;
gcc_assert (src->n_var_parts);
@@ -1196,7 +1309,8 @@ variable_union (void **slot, void *data)
thus there are at most MAX_VAR_PARTS different offsets. */
gcc_assert (k <= MAX_VAR_PARTS);
- if (dst->refcount > 1 && dst->n_var_parts != k)
+ if ((dst->refcount > 1 || shared_hash_shared (set->vars))
+ && dst->n_var_parts != k)
{
enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
@@ -1226,7 +1340,7 @@ variable_union (void **slot, void *data)
/* If DST is shared compare the location chains.
If they are different we will modify the chain in DST with
high probability so make a copy of DST. */
- if (dst->refcount > 1)
+ if (dst->refcount > 1 || shared_hash_shared (set->vars))
{
for (node = src->var_part[i].loc_chain,
node2 = dst->var_part[j].loc_chain; node && node2;
@@ -1379,6 +1493,46 @@ variable_union (void **slot, void *data)
return 1;
}
+/* Like variable_union, but only used when doing dataflow_set_union
+ into an empty hashtab. To allow sharing, dst is initially shared
+ with src (so all variables are "copied" from src to dst hashtab),
+ so only unshare_variable for variables that need canonicalization
+ are needed. */
+
+static int
+variable_canonicalize (void **slot, void *data)
+{
+ variable src;
+ dataflow_set *set = (dataflow_set *) data;
+ int k;
+
+ src = *(variable *) slot;
+
+ /* If CUR_LOC of some variable part is not the first element of
+ the location chain we are going to change it so we have to make
+ a copy of the variable. */
+ for (k = 0; k < src->n_var_parts; k++)
+ {
+ gcc_assert (!src->var_part[k].loc_chain == !src->var_part[k].cur_loc);
+ if (src->var_part[k].loc_chain)
+ {
+ gcc_assert (src->var_part[k].cur_loc);
+ if (src->var_part[k].cur_loc != src->var_part[k].loc_chain->loc)
+ break;
+ }
+ }
+ if (k < src->n_var_parts)
+ {
+ enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
+
+ if (! flag_var_tracking_uninit)
+ status = VAR_INIT_STATUS_INITIALIZED;
+
+ unshare_variable (set, src, status);
+ }
+ return 1;
+}
+
/* Compute union of dataflow sets SRC and DST and store it to DST. */
static void
@@ -1389,7 +1543,14 @@ dataflow_set_union (dataflow_set *dst, d
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
attrs_list_union (&dst->regs[i], src->regs[i]);
- htab_traverse (src->vars, variable_union, dst);
+ if (dst->vars == empty_shared_hash)
+ {
+ shared_hash_destroy (dst->vars);
+ dst->vars = shared_hash_copy (src->vars);
+ htab_traverse (shared_hash_htab (src->vars), variable_canonicalize, dst);
+ }
+ else
+ htab_traverse (shared_hash_htab (src->vars), variable_union, dst);
}
/* Flag whether two dataflow sets being compared contain different data. */
@@ -1522,15 +1683,24 @@ dataflow_set_different_2 (void **slot, v
static bool
dataflow_set_different (dataflow_set *old_set, dataflow_set *new_set)
{
+ if (old_set->vars == new_set->vars)
+ return false;
+
+ if (htab_elements (shared_hash_htab (old_set->vars))
+ != htab_elements (shared_hash_htab (new_set->vars)))
+ return true;
+
dataflow_set_different_value = false;
- htab_traverse (old_set->vars, dataflow_set_different_1, new_set->vars);
+ htab_traverse (shared_hash_htab (old_set->vars), dataflow_set_different_1,
+ shared_hash_htab (new_set->vars));
if (!dataflow_set_different_value)
{
/* We have compared the variables which are in both hash tables
so now only check whether there are some variables in NEW_SET->VARS
which are not in OLD_SET->VARS. */
- htab_traverse (new_set->vars, dataflow_set_different_2, old_set->vars);
+ htab_traverse (shared_hash_htab (new_set->vars), dataflow_set_different_2,
+ shared_hash_htab (old_set->vars));
}
return dataflow_set_different_value;
}
@@ -1545,7 +1715,7 @@ dataflow_set_destroy (dataflow_set *set)
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
attrs_list_clear (&set->regs[i]);
- htab_delete (set->vars);
+ shared_hash_destroy (set->vars);
set->vars = NULL;
}
@@ -1985,7 +2155,6 @@ find_src_set_src (dataflow_set *set, rtx
{
tree decl = NULL_TREE; /* The variable being copied around. */
rtx set_src = NULL_RTX; /* The value for "decl" stored in "src". */
- void **slot;
variable var;
location_chain nextp;
int i;
@@ -1998,12 +2167,9 @@ find_src_set_src (dataflow_set *set, rtx
if (src && decl)
{
- slot = htab_find_slot_with_hash (set->vars, decl,
- VARIABLE_HASH_VAL (decl), NO_INSERT);
-
- if (slot)
+ var = shared_hash_find (set->vars, decl);
+ if (var)
{
- var = *(variable *) slot;
found = false;
for (i = 0; i < var->n_var_parts && !found; i++)
for (nextp = var->var_part[i].loc_chain; nextp && !found;
@@ -2031,7 +2197,7 @@ compute_bb_dataflow (basic_block bb)
dataflow_set *in = &VTI (bb)->in;
dataflow_set *out = &VTI (bb)->out;
- dataflow_set_init (&old_out, htab_elements (VTI (bb)->out.vars) + 3);
+ dataflow_set_init (&old_out);
dataflow_set_copy (&old_out, out);
dataflow_set_copy (out, in);
@@ -2323,7 +2489,7 @@ dump_dataflow_set (dataflow_set *set)
dump_attrs_list (set->regs[i]);
}
}
- dump_vars (set->vars);
+ dump_vars (shared_hash_htab (set->vars));
fprintf (dump_file, "\n");
}
@@ -2345,10 +2511,10 @@ dump_dataflow_sets (void)
}
/* Add variable VAR to the hash table of changed variables and
- if it has no locations delete it from hash table HTAB. */
+ if it has no locations delete it from SET's hash table. */
static void
-variable_was_changed (variable var, htab_t htab)
+variable_was_changed (variable var, dataflow_set *set)
{
hashval_t hash = VARIABLE_HASH_VAL (var->decl);
@@ -2359,36 +2525,39 @@ variable_was_changed (variable var, htab
slot = (variable *) htab_find_slot_with_hash (changed_variables,
var->decl, hash, INSERT);
- if (htab && var->n_var_parts == 0)
+ if (set && var->n_var_parts == 0)
{
variable empty_var;
- void **old;
empty_var = (variable) pool_alloc (var_pool);
empty_var->decl = var->decl;
empty_var->refcount = 1;
empty_var->n_var_parts = 0;
*slot = empty_var;
-
- old = htab_find_slot_with_hash (htab, var->decl, hash,
- NO_INSERT);
- if (old)
- htab_clear_slot (htab, old);
+ goto drop_var;
}
else
{
+ var->refcount++;
*slot = var;
}
}
else
{
- gcc_assert (htab);
+ gcc_assert (set);
if (var->n_var_parts == 0)
{
- void **slot = htab_find_slot_with_hash (htab, var->decl, hash,
- NO_INSERT);
+ void **slot;
+
+ drop_var:
+ slot = shared_hash_find_slot_noinsert (set->vars, var->decl);
if (slot)
- htab_clear_slot (htab, slot);
+ {
+ if (shared_hash_shared (set->vars))
+ slot = shared_hash_find_slot_unshare (&set->vars, var->decl,
+ NO_INSERT);
+ htab_clear_slot (shared_hash_htab (set->vars), slot);
+ }
}
}
}
@@ -2438,12 +2607,12 @@ set_variable_part (dataflow_set *set, rt
location_chain node, next;
location_chain *nextp;
variable var;
- void **slot;
-
- slot = htab_find_slot_with_hash (set->vars, decl,
- VARIABLE_HASH_VAL (decl), INSERT);
- if (!*slot)
+ void **slot = shared_hash_find_slot (set->vars, decl);
+
+ if (!slot || !*slot)
{
+ if (!slot)
+ slot = shared_hash_find_slot_unshare (&set->vars, decl, INSERT);
/* Create new variable information. */
var = (variable) pool_alloc (var_pool);
var->decl = decl;
@@ -2479,13 +2648,12 @@ set_variable_part (dataflow_set *set, rt
if (set_src != NULL)
node->set_src = set_src;
- *slot = var;
return;
}
else
{
/* We have to make a copy of a shared variable. */
- if (var->refcount > 1)
+ if (var->refcount > 1 || shared_hash_shared (set->vars))
var = unshare_variable (set, var, initialized);
}
}
@@ -2494,7 +2662,7 @@ set_variable_part (dataflow_set *set, rt
/* We have not found the location part, new one will be created. */
/* We have to make a copy of the shared variable. */
- if (var->refcount > 1)
+ if (var->refcount > 1 || shared_hash_shared (set->vars))
var = unshare_variable (set, var, initialized);
/* We track only variables whose size is <= MAX_VAR_PARTS bytes
@@ -2548,7 +2716,7 @@ set_variable_part (dataflow_set *set, rt
if (var->var_part[pos].cur_loc == NULL)
{
var->var_part[pos].cur_loc = loc;
- variable_was_changed (var, set->vars);
+ variable_was_changed (var, set);
}
}
@@ -2561,16 +2729,14 @@ static void
clobber_variable_part (dataflow_set *set, rtx loc, tree decl,
HOST_WIDE_INT offset, rtx set_src)
{
- void **slot;
+ variable var;
if (! decl || ! DECL_P (decl))
return;
- slot = htab_find_slot_with_hash (set->vars, decl, VARIABLE_HASH_VAL (decl),
- NO_INSERT);
- if (slot)
+ var = shared_hash_find (set->vars, decl);
+ if (var)
{
- variable var = (variable) *slot;
int pos = find_variable_location_part (var, offset, NULL);
if (pos >= 0)
@@ -2627,13 +2793,9 @@ static void
delete_variable_part (dataflow_set *set, rtx loc, tree decl,
HOST_WIDE_INT offset)
{
- void **slot;
-
- slot = htab_find_slot_with_hash (set->vars, decl, VARIABLE_HASH_VAL (decl),
- NO_INSERT);
- if (slot)
+ variable var = shared_hash_find (set->vars, decl);;
+ if (var)
{
- variable var = (variable) *slot;
int pos = find_variable_location_part (var, offset, NULL);
if (pos >= 0)
@@ -2642,7 +2804,7 @@ delete_variable_part (dataflow_set *set,
location_chain *nextp;
bool changed;
- if (var->refcount > 1)
+ if (var->refcount > 1 || shared_hash_shared (set->vars))
{
/* If the variable contains the location part we have to
make a copy of the variable. */
@@ -2705,7 +2867,7 @@ delete_variable_part (dataflow_set *set,
}
}
if (changed)
- variable_was_changed (var, set->vars);
+ variable_was_changed (var, set);
}
}
}
@@ -2864,14 +3026,6 @@ emit_note_insn_var_location (void **varp
htab_clear_slot (changed_variables, varp);
- /* When there are no location parts the variable has been already
- removed from hash table and a new empty variable was created.
- Free the empty variable. */
- if (var->n_var_parts == 0)
- {
- pool_free (var_pool, var);
- }
-
/* Continue traversing the hash table. */
return 1;
}
@@ -2910,7 +3064,7 @@ emit_notes_for_differences_1 (void **slo
empty_var = (variable) pool_alloc (var_pool);
empty_var->decl = old_var->decl;
- empty_var->refcount = 1;
+ empty_var->refcount = 0;
empty_var->n_var_parts = 0;
variable_was_changed (empty_var, NULL);
}
@@ -2952,8 +3106,12 @@ static void
emit_notes_for_differences (rtx insn, dataflow_set *old_set,
dataflow_set *new_set)
{
- htab_traverse (old_set->vars, emit_notes_for_differences_1, new_set->vars);
- htab_traverse (new_set->vars, emit_notes_for_differences_2, old_set->vars);
+ htab_traverse (shared_hash_htab (old_set->vars),
+ emit_notes_for_differences_1,
+ shared_hash_htab (new_set->vars));
+ htab_traverse (shared_hash_htab (new_set->vars),
+ emit_notes_for_differences_2,
+ shared_hash_htab (old_set->vars));
emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
}
@@ -2965,7 +3123,7 @@ emit_notes_in_bb (basic_block bb)
int i;
dataflow_set set;
- dataflow_set_init (&set, htab_elements (VTI (bb)->in.vars) + 3);
+ dataflow_set_init (&set);
dataflow_set_copy (&set, &VTI (bb)->in);
for (i = 0; i < VTI (bb)->n_mos; i++)
@@ -3098,7 +3256,7 @@ vt_emit_notes (void)
delete_variable_part). */
emit_notes = true;
- dataflow_set_init (&empty, 7);
+ dataflow_set_init (&empty);
last_out = &empty;
FOR_EACH_BB (bb)
@@ -3343,14 +3501,6 @@ vt_initialize (void)
}
}
- /* Init the IN and OUT sets. */
- FOR_ALL_BB (bb)
- {
- VTI (bb)->visited = false;
- dataflow_set_init (&VTI (bb)->in, 7);
- dataflow_set_init (&VTI (bb)->out, 7);
- }
-
attrs_pool = create_alloc_pool ("attrs_def pool",
sizeof (struct attrs_def), 1024);
var_pool = create_alloc_pool ("variable_def pool",
@@ -3358,8 +3508,24 @@ vt_initialize (void)
loc_chain_pool = create_alloc_pool ("location_chain_def pool",
sizeof (struct location_chain_def),
1024);
+ shared_hash_pool = create_alloc_pool ("shared_hash_def pool",
+ sizeof (struct shared_hash_def), 256);
+ empty_shared_hash = (shared_hash) pool_alloc (shared_hash_pool);
+ empty_shared_hash->refcount = 1;
+ empty_shared_hash->htab
+ = htab_create (1, variable_htab_hash, variable_htab_eq,
+ variable_htab_free);
changed_variables = htab_create (10, variable_htab_hash, variable_htab_eq,
- NULL);
+ variable_htab_free);
+
+ /* Init the IN and OUT sets. */
+ FOR_ALL_BB (bb)
+ {
+ VTI (bb)->visited = false;
+ dataflow_set_init (&VTI (bb)->in);
+ dataflow_set_init (&VTI (bb)->out);
+ }
+
vt_add_function_parameters ();
}
@@ -3381,10 +3547,12 @@ vt_finalize (void)
dataflow_set_destroy (&VTI (bb)->out);
}
free_aux_for_blocks ();
+ htab_delete (empty_shared_hash->htab);
+ htab_delete (changed_variables);
free_alloc_pool (attrs_pool);
free_alloc_pool (var_pool);
free_alloc_pool (loc_chain_pool);
- htab_delete (changed_variables);
+ free_alloc_pool (shared_hash_pool);
}
/* The entry point to variable tracking pass. */
--- libiberty/hashtab.c (revision 148758)
+++ libiberty/hashtab.c (revision 148760)
@@ -759,7 +759,8 @@ htab_traverse_noresize (htab_t htab, hta
void
htab_traverse (htab_t htab, htab_trav callback, PTR info)
{
- if (htab_elements (htab) * 8 < htab_size (htab))
+ size_t size = htab_size (htab);
+ if (htab_elements (htab) * 8 < size && size > 32)
htab_expand (htab);
htab_traverse_noresize (htab, callback, info);

View File

@ -1,491 +0,0 @@
2009-06-23 Jakub Jelinek <jakub@redhat.com>
* var-tracking.c (unshare_variable): Force initialized to
be VAR_INIT_STATUS_INITIALIZED unless flag_var_tracking_uninit.
(set_variable_part): Likewise.
(struct variable_union_info): Remove pos_src field.
(vui_vec, vui_allocated): New variables.
(variable_union): Pass VAR_INIT_STATUS_UNKNOWN to unshare_variable
unconditionally. Avoid XCVECNEW/free for every sorting, for dst_l
== 1 use a simpler sorting algorithm. Compute pos field right
away, don't fill in pos_src. For dst_l == 2 avoid qsort.
Avoid quadratic comparison if !flag_var_tracking_uninit.
(variable_canonicalize): Pass VAR_INIT_STATUS_UNKNOWN to
unshare_variable unconditionally.
(dataflow_set_different_2): Removed.
(dataflow_set_different): Don't traverse second hash table.
(compute_bb_dataflow): Pass VAR_INIT_STATUS_UNINITIALIZED
unconditionally to var_reg_set or var_mem_set.
(emit_notes_in_bb): Likewise.
(delete_variable_part): Pass VAR_INIT_STATUS_UNKNOWN to
unshare_variable.
(emit_note_insn_var_location): Don't set initialized to
VAR_INIT_STATUS_INITIALIZED early.
(vt_finalize): Free vui_vec if needed, clear vui_vec and
vui_allocated.
--- gcc/var-tracking.c (revision 148851)
+++ gcc/var-tracking.c (revision 148852)
@@ -347,7 +347,6 @@ static void dataflow_set_union (dataflow
static bool variable_part_different_p (variable_part *, variable_part *);
static bool variable_different_p (variable, variable, bool);
static int dataflow_set_different_1 (void **, void *);
-static int dataflow_set_different_2 (void **, void *);
static bool dataflow_set_different (dataflow_set *, dataflow_set *);
static void dataflow_set_destroy (dataflow_set *);
@@ -878,6 +877,9 @@ unshare_variable (dataflow_set *set, var
var->refcount--;
new_var->n_var_parts = var->n_var_parts;
+ if (! flag_var_tracking_uninit)
+ initialized = VAR_INIT_STATUS_INITIALIZED;
+
for (i = 0; i < var->n_var_parts; i++)
{
location_chain node;
@@ -1202,11 +1204,14 @@ struct variable_union_info
/* The sum of positions in the input chains. */
int pos;
- /* The position in the chains of SRC and DST dataflow sets. */
- int pos_src;
+ /* The position in the chain of DST dataflow set. */
int pos_dst;
};
+/* Buffer for location list sorting and its allocated size. */
+static struct variable_union_info *vui_vec;
+static int vui_allocated;
+
/* Compare function for qsort, order the structures by POS element. */
static int
@@ -1263,14 +1268,9 @@ variable_union (void **slot, void *data)
}
if (k < src->n_var_parts)
{
- enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
-
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
-
if (dstp)
*dstp = (void *) src;
- unshare_variable (set, src, status);
+ unshare_variable (set, src, VAR_INIT_STATUS_UNKNOWN);
}
else
{
@@ -1311,13 +1311,7 @@ variable_union (void **slot, void *data)
if ((dst->refcount > 1 || shared_hash_shared (set->vars))
&& dst->n_var_parts != k)
- {
- enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
-
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
- dst = unshare_variable (set, dst, status);
- }
+ dst = unshare_variable (set, dst, VAR_INIT_STATUS_UNKNOWN);
i = src->n_var_parts - 1;
j = dst->n_var_parts - 1;
@@ -1366,70 +1360,152 @@ variable_union (void **slot, void *data)
dst_l = 0;
for (node = dst->var_part[j].loc_chain; node; node = node->next)
dst_l++;
- vui = XCNEWVEC (struct variable_union_info, src_l + dst_l);
- /* Fill in the locations from DST. */
- for (node = dst->var_part[j].loc_chain, jj = 0; node;
- node = node->next, jj++)
+ if (dst_l == 1)
{
- vui[jj].lc = node;
- vui[jj].pos_dst = jj;
+ /* The most common case, much simpler, no qsort is needed. */
+ location_chain dstnode = dst->var_part[j].loc_chain;
+ dst->var_part[k].loc_chain = dstnode;
+ dst->var_part[k].offset = dst->var_part[j].offset;
+ node2 = dstnode;
+ for (node = src->var_part[i].loc_chain; node; node = node->next)
+ if (!((REG_P (dstnode->loc)
+ && REG_P (node->loc)
+ && REGNO (dstnode->loc) == REGNO (node->loc))
+ || rtx_equal_p (dstnode->loc, node->loc)))
+ {
+ location_chain new_node;
- /* Value larger than a sum of 2 valid positions. */
- vui[jj].pos_src = src_l + dst_l;
+ /* Copy the location from SRC. */
+ new_node = (location_chain) pool_alloc (loc_chain_pool);
+ new_node->loc = node->loc;
+ new_node->init = node->init;
+ if (!node->set_src || MEM_P (node->set_src))
+ new_node->set_src = NULL;
+ else
+ new_node->set_src = node->set_src;
+ node2->next = new_node;
+ node2 = new_node;
+ }
+ node2->next = NULL;
}
-
- /* Fill in the locations from SRC. */
- n = dst_l;
- for (node = src->var_part[i].loc_chain, ii = 0; node;
- node = node->next, ii++)
+ else
{
- /* Find location from NODE. */
- for (jj = 0; jj < dst_l; jj++)
+ if (src_l + dst_l > vui_allocated)
{
- if ((REG_P (vui[jj].lc->loc)
- && REG_P (node->loc)
- && REGNO (vui[jj].lc->loc) == REGNO (node->loc))
- || rtx_equal_p (vui[jj].lc->loc, node->loc))
- {
- vui[jj].pos_src = ii;
- break;
- }
+ vui_allocated = MAX (vui_allocated * 2, src_l + dst_l);
+ vui_vec = XRESIZEVEC (struct variable_union_info, vui_vec,
+ vui_allocated);
}
- if (jj >= dst_l) /* The location has not been found. */
+ vui = vui_vec;
+
+ /* Fill in the locations from DST. */
+ for (node = dst->var_part[j].loc_chain, jj = 0; node;
+ node = node->next, jj++)
{
- location_chain new_node;
+ vui[jj].lc = node;
+ vui[jj].pos_dst = jj;
- /* Copy the location from SRC. */
- new_node = (location_chain) pool_alloc (loc_chain_pool);
- new_node->loc = node->loc;
- new_node->init = node->init;
- if (!node->set_src || MEM_P (node->set_src))
- new_node->set_src = NULL;
- else
- new_node->set_src = node->set_src;
- vui[n].lc = new_node;
- vui[n].pos_src = ii;
- vui[n].pos_dst = src_l + dst_l;
- n++;
+ /* Pos plus value larger than a sum of 2 valid positions. */
+ vui[jj].pos = jj + src_l + dst_l;
}
- }
- for (ii = 0; ii < src_l + dst_l; ii++)
- vui[ii].pos = vui[ii].pos_src + vui[ii].pos_dst;
+ /* Fill in the locations from SRC. */
+ n = dst_l;
+ for (node = src->var_part[i].loc_chain, ii = 0; node;
+ node = node->next, ii++)
+ {
+ /* Find location from NODE. */
+ for (jj = 0; jj < dst_l; jj++)
+ {
+ if ((REG_P (vui[jj].lc->loc)
+ && REG_P (node->loc)
+ && REGNO (vui[jj].lc->loc) == REGNO (node->loc))
+ || rtx_equal_p (vui[jj].lc->loc, node->loc))
+ {
+ vui[jj].pos = jj + ii;
+ break;
+ }
+ }
+ if (jj >= dst_l) /* The location has not been found. */
+ {
+ location_chain new_node;
- qsort (vui, n, sizeof (struct variable_union_info),
- variable_union_info_cmp_pos);
+ /* Copy the location from SRC. */
+ new_node = (location_chain) pool_alloc (loc_chain_pool);
+ new_node->loc = node->loc;
+ new_node->init = node->init;
+ if (!node->set_src || MEM_P (node->set_src))
+ new_node->set_src = NULL;
+ else
+ new_node->set_src = node->set_src;
+ vui[n].lc = new_node;
+ vui[n].pos_dst = src_l + dst_l;
+ vui[n].pos = ii + src_l + dst_l;
+ n++;
+ }
+ }
- /* Reconnect the nodes in sorted order. */
- for (ii = 1; ii < n; ii++)
- vui[ii - 1].lc->next = vui[ii].lc;
- vui[n - 1].lc->next = NULL;
+ if (dst_l == 2)
+ {
+ /* Special case still very common case. For dst_l == 2
+ all entries dst_l ... n-1 are sorted, with for i >= dst_l
+ vui[i].pos == i + src_l + dst_l. */
+ if (vui[0].pos > vui[1].pos)
+ {
+ /* Order should be 1, 0, 2... */
+ dst->var_part[k].loc_chain = vui[1].lc;
+ vui[1].lc->next = vui[0].lc;
+ if (n >= 3)
+ {
+ vui[0].lc->next = vui[2].lc;
+ vui[n - 1].lc->next = NULL;
+ }
+ else
+ vui[0].lc->next = NULL;
+ ii = 3;
+ }
+ else
+ {
+ dst->var_part[k].loc_chain = vui[0].lc;
+ if (n >= 3 && vui[2].pos < vui[1].pos)
+ {
+ /* Order should be 0, 2, 1, 3... */
+ vui[0].lc->next = vui[2].lc;
+ vui[2].lc->next = vui[1].lc;
+ if (n >= 4)
+ {
+ vui[1].lc->next = vui[3].lc;
+ vui[n - 1].lc->next = NULL;
+ }
+ else
+ vui[1].lc->next = NULL;
+ ii = 4;
+ }
+ else
+ {
+ /* Order should be 0, 1, 2... */
+ ii = 1;
+ vui[n - 1].lc->next = NULL;
+ }
+ }
+ for (; ii < n; ii++)
+ vui[ii - 1].lc->next = vui[ii].lc;
+ }
+ else
+ {
+ qsort (vui, n, sizeof (struct variable_union_info),
+ variable_union_info_cmp_pos);
- dst->var_part[k].loc_chain = vui[0].lc;
- dst->var_part[k].offset = dst->var_part[j].offset;
+ /* Reconnect the nodes in sorted order. */
+ for (ii = 1; ii < n; ii++)
+ vui[ii - 1].lc->next = vui[ii].lc;
+ vui[n - 1].lc->next = NULL;
+ dst->var_part[k].loc_chain = vui[0].lc;
+ }
- free (vui);
+ dst->var_part[k].offset = dst->var_part[j].offset;
+ }
i--;
j--;
}
@@ -1477,17 +1553,18 @@ variable_union (void **slot, void *data)
dst->var_part[k].cur_loc = NULL;
}
- for (i = 0; i < src->n_var_parts && i < dst->n_var_parts; i++)
- {
- location_chain node, node2;
- for (node = src->var_part[i].loc_chain; node; node = node->next)
- for (node2 = dst->var_part[i].loc_chain; node2; node2 = node2->next)
- if (rtx_equal_p (node->loc, node2->loc))
- {
- if (node->init > node2->init)
- node2->init = node->init;
- }
- }
+ if (flag_var_tracking_uninit)
+ for (i = 0; i < src->n_var_parts && i < dst->n_var_parts; i++)
+ {
+ location_chain node, node2;
+ for (node = src->var_part[i].loc_chain; node; node = node->next)
+ for (node2 = dst->var_part[i].loc_chain; node2; node2 = node2->next)
+ if (rtx_equal_p (node->loc, node2->loc))
+ {
+ if (node->init > node2->init)
+ node2->init = node->init;
+ }
+ }
/* Continue traversing the hash table. */
return 1;
@@ -1522,14 +1599,7 @@ variable_canonicalize (void **slot, void
}
}
if (k < src->n_var_parts)
- {
- enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
-
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
-
- unshare_variable (set, src, status);
- }
+ unshare_variable (set, src, VAR_INIT_STATUS_UNKNOWN);
return 1;
}
@@ -1650,34 +1720,6 @@ dataflow_set_different_1 (void **slot, v
return 1;
}
-/* Compare variable *SLOT with the same variable in hash table DATA
- and set DATAFLOW_SET_DIFFERENT_VALUE if they are different. */
-
-static int
-dataflow_set_different_2 (void **slot, void *data)
-{
- htab_t htab = (htab_t) data;
- variable var1, var2;
-
- var1 = *(variable *) slot;
- var2 = (variable) htab_find_with_hash (htab, var1->decl,
- VARIABLE_HASH_VAL (var1->decl));
- if (!var2)
- {
- dataflow_set_different_value = true;
-
- /* Stop traversing the hash table. */
- return 0;
- }
-
- /* If both variables are defined they have been already checked for
- equivalence. */
- gcc_assert (!variable_different_p (var1, var2, false));
-
- /* Continue traversing the hash table. */
- return 1;
-}
-
/* Return true if dataflow sets OLD_SET and NEW_SET differ. */
static bool
@@ -1694,14 +1736,9 @@ dataflow_set_different (dataflow_set *ol
htab_traverse (shared_hash_htab (old_set->vars), dataflow_set_different_1,
shared_hash_htab (new_set->vars));
- if (!dataflow_set_different_value)
- {
- /* We have compared the variables which are in both hash tables
- so now only check whether there are some variables in NEW_SET->VARS
- which are not in OLD_SET->VARS. */
- htab_traverse (shared_hash_htab (new_set->vars), dataflow_set_different_2,
- shared_hash_htab (old_set->vars));
- }
+ /* No need to traverse the second hashtab, if both have the same number
+ of elements and the second one had all entries found in the first one,
+ then it can't have any extra entries. */
return dataflow_set_different_value;
}
@@ -2215,15 +2252,11 @@ compute_bb_dataflow (basic_block bb)
case MO_USE:
{
rtx loc = VTI (bb)->mos[i].u.loc;
- enum var_init_status status = VAR_INIT_STATUS_UNINITIALIZED;
-
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
if (GET_CODE (loc) == REG)
- var_reg_set (out, loc, status, NULL);
+ var_reg_set (out, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
else if (GET_CODE (loc) == MEM)
- var_mem_set (out, loc, status, NULL);
+ var_mem_set (out, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
}
break;
@@ -2262,10 +2295,12 @@ compute_bb_dataflow (basic_block bb)
if (! flag_var_tracking_uninit)
src_status = VAR_INIT_STATUS_INITIALIZED;
else
- src_status = find_src_status (in, set_src);
+ {
+ src_status = find_src_status (in, set_src);
- if (src_status == VAR_INIT_STATUS_UNKNOWN)
- src_status = find_src_status (out, set_src);
+ if (src_status == VAR_INIT_STATUS_UNKNOWN)
+ src_status = find_src_status (out, set_src);
+ }
set_src = find_src_set_src (in, set_src);
@@ -2609,6 +2644,9 @@ set_variable_part (dataflow_set *set, rt
variable var;
void **slot = shared_hash_find_slot (set->vars, decl);
+ if (! flag_var_tracking_uninit)
+ initialized = VAR_INIT_STATUS_INITIALIZED;
+
if (!slot || !*slot)
{
if (!slot)
@@ -2815,10 +2853,8 @@ delete_variable_part (dataflow_set *set,
&& REGNO (node->loc) == REGNO (loc))
|| rtx_equal_p (node->loc, loc))
{
- enum var_init_status status = VAR_INIT_STATUS_UNKNOWN;
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
- var = unshare_variable (set, var, status);
+ var = unshare_variable (set, var,
+ VAR_INIT_STATUS_UNKNOWN);
break;
}
}
@@ -2893,9 +2929,6 @@ emit_note_insn_var_location (void **varp
gcc_assert (var->decl);
- if (! flag_var_tracking_uninit)
- initialized = VAR_INIT_STATUS_INITIALIZED;
-
complete = true;
last_limit = 0;
n_var_parts = 0;
@@ -3148,14 +3181,11 @@ emit_notes_in_bb (basic_block bb)
case MO_USE:
{
rtx loc = VTI (bb)->mos[i].u.loc;
-
- enum var_init_status status = VAR_INIT_STATUS_UNINITIALIZED;
- if (! flag_var_tracking_uninit)
- status = VAR_INIT_STATUS_INITIALIZED;
+
if (GET_CODE (loc) == REG)
- var_reg_set (&set, loc, status, NULL);
+ var_reg_set (&set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
else
- var_mem_set (&set, loc, status, NULL);
+ var_mem_set (&set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
}
@@ -3553,6 +3583,10 @@ vt_finalize (void)
free_alloc_pool (var_pool);
free_alloc_pool (loc_chain_pool);
free_alloc_pool (shared_hash_pool);
+ if (vui_vec)
+ free (vui_vec);
+ vui_vec = NULL;
+ vui_allocated = 0;
}
/* The entry point to variable tracking pass. */

View File

@ -0,0 +1,151 @@
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41248
* cfgexpand.c (convert_debug_memory_address): New.
(expand_debug_expr): Convert base address and offset to the same
mode. Use it to convert addresses to other modes. Accept
ptr_mode addresses.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41248
* gcc.dg/pr41248.c: New.
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c.orig 2009-09-07 19:00:20.000000000 -0300
+++ gcc/cfgexpand.c 2009-09-07 19:17:27.000000000 -0300
@@ -1966,6 +1966,38 @@ unwrap_constant (rtx x)
return ret;
}
+/* Convert X to MODE, that must be Pmode or ptr_mode, without emitting
+ any rtl. */
+
+static rtx
+convert_debug_memory_address (enum machine_mode mode, rtx x)
+{
+ enum machine_mode xmode = GET_MODE (x);
+
+#ifndef POINTERS_EXTEND_UNSIGNED
+ gcc_assert (mode == Pmode);
+ gcc_assert (xmode == mode || xmode == VOIDmode);
+#else
+ gcc_assert (mode == Pmode || mode == ptr_mode);
+
+ if (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode)
+ return x;
+
+ if (GET_MODE_BITSIZE (mode) < GET_MODE_BITSIZE (xmode))
+ x = simplify_gen_subreg (mode, x, xmode,
+ subreg_lowpart_offset
+ (mode, xmode));
+ else if (POINTERS_EXTEND_UNSIGNED > 0)
+ x = gen_rtx_ZERO_EXTEND (mode, x);
+ else if (!POINTERS_EXTEND_UNSIGNED)
+ x = gen_rtx_SIGN_EXTEND (mode, x);
+ else
+ gcc_unreachable ();
+#endif /* POINTERS_EXTEND_UNSIGNED */
+
+ return x;
+}
+
/* Return an RTX equivalent to the value of the tree expression
EXP. */
@@ -2141,6 +2173,7 @@ expand_debug_expr (tree exp)
return NULL;
gcc_assert (GET_MODE (op0) == Pmode
+ || GET_MODE (op0) == ptr_mode
|| GET_CODE (op0) == CONST_INT
|| GET_CODE (op0) == CONST_DOUBLE);
@@ -2167,6 +2200,7 @@ expand_debug_expr (tree exp)
return NULL;
gcc_assert (GET_MODE (op0) == Pmode
+ || GET_MODE (op0) == ptr_mode
|| GET_CODE (op0) == CONST_INT
|| GET_CODE (op0) == CONST_DOUBLE);
@@ -2199,13 +2233,32 @@ expand_debug_expr (tree exp)
if (offset)
{
+ enum machine_mode addrmode, offmode;
+
gcc_assert (MEM_P (op0));
+ op0 = XEXP (op0, 0);
+ addrmode = GET_MODE (op0);
+ if (addrmode == VOIDmode)
+ addrmode = Pmode;
+
op1 = expand_debug_expr (offset);
if (!op1)
return NULL;
- op0 = gen_rtx_MEM (mode, gen_rtx_PLUS (Pmode, XEXP (op0, 0), op1));
+ offmode = GET_MODE (op1);
+ if (offmode == VOIDmode)
+ offmode = TYPE_MODE (TREE_TYPE (offset));
+
+ if (addrmode != offmode)
+ op1 = simplify_gen_subreg (addrmode, op1, offmode,
+ subreg_lowpart_offset (addrmode,
+ offmode));
+
+ /* Don't use offset_address here, we don't need a
+ recognizable address, and we don't want to generate
+ code. */
+ op0 = gen_rtx_MEM (mode, gen_rtx_PLUS (addrmode, op0, op1));
}
if (MEM_P (op0))
@@ -2525,7 +2578,9 @@ expand_debug_expr (tree exp)
if (!op0 || !MEM_P (op0))
return NULL;
- return XEXP (op0, 0);
+ op0 = convert_debug_memory_address (mode, XEXP (op0, 0));
+
+ return op0;
case VECTOR_CST:
exp = build_constructor_from_list (TREE_TYPE (exp),
Index: gcc/testsuite/gcc.dg/pr41248.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/pr41248.c 2009-09-07 19:17:27.000000000 -0300
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+struct __gcov_var {
+ unsigned int offset;
+ unsigned int buffer[(1 << 10) + 1];
+} __gcov_var;
+unsigned int * gcov_write_words (unsigned int words) {
+ unsigned int *result;
+ result = &__gcov_var.buffer[__gcov_var.offset];
+ return result;
+}
+
+struct gcov_ctr_summary { };
+struct gcov_summary {
+ unsigned int checksum;
+ struct gcov_ctr_summary ctrs[1];
+};
+void __gcov_write_unsigned (unsigned int);
+void __gcov_write_summary (unsigned int tag,
+ const struct gcov_summary *summary)
+{
+ unsigned ix;
+ const struct gcov_ctr_summary *csum;
+ __gcov_write_unsigned (summary->checksum);
+ for (csum = summary->ctrs, ix = 1; ix--; csum++) { }
+}

View File

@ -0,0 +1,30 @@
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41276
* cselib.c (cselib_expand_value_rtx_1): Don't return copy of
invalid subreg.
Index: gcc/cselib.c
===================================================================
--- gcc/cselib.c.orig 2009-08-14 08:00:12.000000000 -0300
+++ gcc/cselib.c 2009-09-07 19:17:35.000000000 -0300
@@ -1165,12 +1165,12 @@ cselib_expand_value_rtx_1 (rtx orig, str
scopy = simplify_gen_subreg (GET_MODE (orig), subreg,
GET_MODE (SUBREG_REG (orig)),
SUBREG_BYTE (orig));
- if (scopy == NULL
- || (GET_CODE (scopy) == SUBREG
- && !REG_P (SUBREG_REG (scopy))
- && !MEM_P (SUBREG_REG (scopy))
- && (REG_P (SUBREG_REG (orig))
- || MEM_P (SUBREG_REG (orig)))))
+ if ((scopy == NULL
+ || (GET_CODE (scopy) == SUBREG
+ && !REG_P (SUBREG_REG (scopy))
+ && !MEM_P (SUBREG_REG (scopy))))
+ && (REG_P (SUBREG_REG (orig))
+ || MEM_P (SUBREG_REG (orig))))
return shallow_copy_rtx (orig);
return scopy;
}

View File

@ -0,0 +1,207 @@
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* tree-ssa-loop-ivopts.c (get_phi_with_result): Remove.
(remove_statement): Likewise.
(rewrite_use_nonlinear_expr): Adjust.
(remove_unused_ivs): Collect SSA NAMEs to remove and call...
* tree-ssa.c (release_defs_bitset): ... this. New.
* tree-flow.h (release_defs_bitset): Declare.
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c.orig 2009-09-07 19:00:52.000000000 -0300
+++ gcc/tree-ssa-loop-ivopts.c 2009-09-07 19:15:39.000000000 -0300
@@ -5038,42 +5038,6 @@ create_new_ivs (struct ivopts_data *data
}
}
-/* Returns the phi-node in BB with result RESULT. */
-
-static gimple
-get_phi_with_result (basic_block bb, tree result)
-{
- gimple_stmt_iterator i = gsi_start_phis (bb);
-
- for (; !gsi_end_p (i); gsi_next (&i))
- if (gimple_phi_result (gsi_stmt (i)) == result)
- return gsi_stmt (i);
-
- gcc_unreachable ();
- return NULL;
-}
-
-
-/* Removes statement STMT (real or a phi node). If INCLUDING_DEFINED_NAME
- is true, remove also the ssa name defined by the statement. */
-
-static void
-remove_statement (gimple stmt, bool including_defined_name)
-{
- if (gimple_code (stmt) == GIMPLE_PHI)
- {
- gimple bb_phi = get_phi_with_result (gimple_bb (stmt),
- gimple_phi_result (stmt));
- gimple_stmt_iterator bsi = gsi_for_stmt (bb_phi);
- remove_phi_node (&bsi, including_defined_name);
- }
- else
- {
- gimple_stmt_iterator bsi = gsi_for_stmt (stmt);
- gsi_remove (&bsi, true);
- release_defs (stmt);
- }
-}
/* Rewrites USE (definition of iv used in a nonlinear expression)
using candidate CAND. */
@@ -5176,7 +5140,9 @@ rewrite_use_nonlinear_expr (struct ivopt
{
ass = gimple_build_assign (tgt, op);
gsi_insert_before (&bsi, ass, GSI_SAME_STMT);
- remove_statement (use->stmt, false);
+
+ bsi = gsi_for_stmt (use->stmt);
+ remove_phi_node (&bsi, false);
}
else
{
@@ -5414,7 +5380,11 @@ remove_unused_ivs (struct ivopts_data *d
{
unsigned j;
bitmap_iterator bi;
+ bitmap toremove = BITMAP_ALLOC (NULL);
+ /* Figure out an order in which to release SSA DEFs so that we don't
+ release something that we'd have to propagate into a debug stmt
+ afterwards. */
EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, j, bi)
{
struct version_info *info;
@@ -5425,25 +5395,12 @@ remove_unused_ivs (struct ivopts_data *d
&& !info->inv_id
&& !info->iv->have_use_for
&& !info->preserve_biv)
- {
- if (MAY_HAVE_DEBUG_STMTS)
- {
- gimple stmt;
- imm_use_iterator iter;
-
- FOR_EACH_IMM_USE_STMT (stmt, iter, info->iv->ssa_name)
- {
- if (!gimple_debug_bind_p (stmt))
- continue;
-
- /* ??? We can probably do better than this. */
- gimple_debug_bind_reset_value (stmt);
- update_stmt (stmt);
- }
- }
- remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true);
- }
+ bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name));
}
+
+ release_defs_bitset (toremove);
+
+ BITMAP_FREE (toremove);
}
/* Frees data allocated by the optimization of a single loop. */
Index: gcc/tree-flow.h
===================================================================
--- gcc/tree-flow.h.orig 2009-07-12 08:19:36.000000000 -0300
+++ gcc/tree-flow.h 2009-09-07 19:15:39.000000000 -0300
@@ -586,9 +586,10 @@ typedef struct
(VAR) = next_referenced_var (&(ITER)))
void propagate_defs_into_debug_stmts (gimple, basic_block,
- const gimple_stmt_iterator *);
+ const gimple_stmt_iterator *);
void propagate_var_def_into_debug_stmts (tree, basic_block,
- const gimple_stmt_iterator *);
+ const gimple_stmt_iterator *);
+void release_defs_bitset (bitmap toremove);
typedef struct
{
Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c.orig 2009-09-01 16:16:04.000000000 -0300
+++ gcc/tree-ssa.c 2009-09-07 19:15:39.000000000 -0300
@@ -440,6 +440,74 @@ propagate_defs_into_debug_stmts (gimple
}
}
+/* Delete SSA DEFs for SSA versions in the TOREMOVE bitmap, removing
+ dominated stmts before their dominators, so that release_ssa_defs
+ stands a chance of propagating DEFs into debug bind stmts. */
+
+void
+release_defs_bitset (bitmap toremove)
+{
+ unsigned j;
+ bitmap_iterator bi;
+
+ /* Performing a topological sort is probably overkill, this will
+ most likely run in slightly superlinear time, rather than the
+ pathological quadratic worst case. */
+ while (!bitmap_empty_p (toremove))
+ EXECUTE_IF_SET_IN_BITMAP (toremove, 0, j, bi)
+ {
+ bool remove_now = true;
+ tree var = ssa_name (j);
+ gimple stmt;
+ imm_use_iterator uit;
+
+ FOR_EACH_IMM_USE_STMT (stmt, uit, var)
+ {
+ ssa_op_iter dit;
+ def_operand_p def_p;
+
+ /* We can't propagate PHI nodes into debug stmts. */
+ if (gimple_code (stmt) == GIMPLE_PHI
+ || is_gimple_debug (stmt))
+ continue;
+
+ /* If we find another definition to remove that uses
+ the one we're looking at, defer the removal of this
+ one, so that it can be propagated into debug stmts
+ after the other is. */
+ FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, dit, SSA_OP_DEF)
+ {
+ tree odef = DEF_FROM_PTR (def_p);
+
+ if (bitmap_bit_p (toremove, SSA_NAME_VERSION (odef)))
+ {
+ remove_now = false;
+ break;
+ }
+ }
+
+ if (!remove_now)
+ BREAK_FROM_IMM_USE_STMT (uit);
+ }
+
+ if (remove_now)
+ {
+ gimple def = SSA_NAME_DEF_STMT (var);
+ gimple_stmt_iterator gsi = gsi_for_stmt (def);
+
+ if (gimple_code (def) == GIMPLE_PHI)
+ remove_phi_node (&gsi, true);
+ else
+ {
+ gsi_remove (&gsi, true);
+ release_defs (def);
+ }
+
+ bitmap_clear_bit (toremove, j);
+ }
+ }
+}
+
/* Return true if SSA_NAME is malformed and mark it visited.
IS_VIRTUAL is true if this SSA_NAME was found inside a virtual

View File

@ -0,0 +1,18 @@
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c.orig 2009-09-07 19:11:47.000000000 -0300
+++ gcc/toplev.c 2009-09-07 19:17:31.000000000 -0300
@@ -1796,7 +1796,12 @@ process_options (void)
if (flag_gtoggle)
{
if (debug_info_level == DINFO_LEVEL_NONE)
- debug_info_level = DINFO_LEVEL_NORMAL;
+ {
+ debug_info_level = DINFO_LEVEL_NORMAL;
+
+ if (write_symbols == NO_DEBUG)
+ write_symbols = PREFERRED_DEBUGGING_TYPE;
+ }
else
debug_info_level = DINFO_LEVEL_NONE;
}

View File

@ -0,0 +1,45 @@
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41232
* tree-ssa-phiopt.c (minmax_replacement): Skip debug stmts
in the middle block.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41232
* gcc.dg/pr41232.c: New.
Index: gcc/testsuite/gcc.dg/pr41232.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/pr41232.c 2009-09-07 19:15:35.000000000 -0300
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -g" } */
+extern int atoi (const char *);
+extern int sprintf (char *, const char *, ...);
+void malloc_init() {
+ char *cptr;
+ char buf[1];
+ int tmbd = atoi(cptr);
+ if (tmbd > 0)
+ tmbd = (tmbd <= 124) ? tmbd : 124;
+ else
+ tmbd = 0;
+ sprintf(buf, "%d\n", tmbd);
+}
Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c.orig 2009-09-07 19:00:29.000000000 -0300
+++ gcc/tree-ssa-phiopt.c 2009-09-07 19:15:35.000000000 -0300
@@ -848,7 +848,7 @@ minmax_replacement (basic_block cond_bb,
/* Move the statement from the middle block. */
gsi = gsi_last_bb (cond_bb);
- gsi_from = gsi_last_bb (middle_bb);
+ gsi_from = gsi_last_nondebug_bb (middle_bb);
gsi_move_before (&gsi_from, &gsi);
}

View File

@ -0,0 +1,41 @@
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41229
* tree-ssa.c (execute_update_addresses_taken): Update debug insns.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41229
* gfortran.dg/pr41229.f90: New.
Index: gcc/testsuite/gfortran.dg/pr41229.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gfortran.dg/pr41229.f90 2009-09-07 19:16:17.000000000 -0300
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-O2 -g" }
+SUBROUTINE cp_fm_triangular_multiply()
+ INTEGER, PARAMETER :: dp=KIND(0.0D0)
+ REAL(dp), ALLOCATABLE, DIMENSION(:) :: tau, work
+ REAL(KIND=dp), DIMENSION(:, :), POINTER :: a
+ ndim = SIZE(a,2)
+ ALLOCATE(tau(ndim),STAT=istat)
+ ALLOCATE(work(2*ndim),STAT=istat)
+END SUBROUTINE
Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c.orig 2009-09-07 19:15:39.000000000 -0300
+++ gcc/tree-ssa.c 2009-09-07 19:17:19.000000000 -0300
@@ -2067,7 +2067,8 @@ execute_update_addresses_taken (void)
if ((gimple_loaded_syms (stmt)
&& bitmap_intersect_p (gimple_loaded_syms (stmt), vars_updated))
|| (gimple_stored_syms (stmt)
- && bitmap_intersect_p (gimple_stored_syms (stmt), vars_updated)))
+ && bitmap_intersect_p (gimple_stored_syms (stmt), vars_updated))
+ || is_gimple_debug (stmt))
update_stmt (stmt);
}
BITMAP_FREE (not_reg_needs);

View File

@ -1,2 +1,2 @@
2659f09c2e43ef8b7d4406321753f1b2 fastjar-0.97.tar.gz
67e50d0590f56a2184121e035c7907c8 gcc-4.4.1-20090903.tar.bz2
12f92325baf664989136ea6c7585273f gcc-4.4.1-20090908.tar.bz2