[patch] Fix bug in variable-tracking
Josef Zlomek
zlomj9am@artax.karlin.mff.cuni.cz
Tue Apr 27 20:43:00 GMT 2004
> I think it would be better if you passed an extra argument to
> variable_different_p. This makes it clearer what the patch is doing.
>
> There is also an efficiency problem with your patch. Because of the way
> it is written, variable_part_different_p must always be called twice
> with the args reversed. The new check you added however is always the
> same regardless of the argument order. Hence it makes more sense to put
> it in variable_different_p than in variable_part_different_p, so that we
> only perform the check once.
I have fixed the patch according to your comments.
Bootstrapped/regtested x86_64 (ia64 in progress).
OK if it passes tests on ia64?
Josef
2004-04-27 Josef Zlomek <zlomekj@suse.cz>
* var-tracking.c (variable_different_p): Add a parameter
compare_current_location, compare current location of variable parts
if it is true.
(dataflow_set_different_1): Pass compare_current_location == false.
(dataflow_set_different_2): Pass compare_current_location == false.
(emit_notes_for_differences_1): Pass compare_current_location == true.
Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/gcc/var-tracking.c,v
retrieving revision 2.15
diff -c -p -c -3 -p -r2.15 var-tracking.c
*** var-tracking.c 22 Apr 2004 12:16:33 -0000 2.15
--- var-tracking.c 27 Apr 2004 14:28:56 -0000
*************** static int variable_union_info_cmp_pos (
*** 304,310 ****
static int variable_union (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);
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 *);
--- 304,310 ----
static int variable_union (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);
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 *);
*************** variable_part_different_p (variable_part
*** 1260,1271 ****
return false;
}
! /* Return true if variables VAR1 and VAR2 are different (only the first
! location in the list of locations is checked for each offset,
! i.e. when true is returned a note should be emitted). */
static bool
! variable_different_p (variable var1, variable var2)
{
int i;
--- 1260,1272 ----
return false;
}
! /* Return true if variables VAR1 and VAR2 are different.
! If COMPARE_CURRENT_LOCATION is true compare also the cur_loc of each
! variable part. */
static bool
! variable_different_p (variable var1, variable var2,
! bool compare_current_location)
{
int i;
*************** variable_different_p (variable var1, var
*** 1279,1284 ****
--- 1280,1295 ----
{
if (var1->var_part[i].offset != var2->var_part[i].offset)
return true;
+ if (compare_current_location)
+ {
+ if (!((GET_CODE (var1->var_part[i].cur_loc) == REG
+ && GET_CODE (var2->var_part[i].cur_loc) == REG
+ && (REGNO (var1->var_part[i].cur_loc)
+ == REGNO (var2->var_part[i].cur_loc)))
+ || rtx_equal_p (var1->var_part[i].cur_loc,
+ var2->var_part[i].cur_loc)))
+ return true;
+ }
if (variable_part_different_p (&var1->var_part[i], &var2->var_part[i]))
return true;
if (variable_part_different_p (&var2->var_part[i], &var1->var_part[i]))
*************** dataflow_set_different_1 (void **slot, v
*** 1307,1313 ****
return 0;
}
! if (variable_different_p (var1, var2))
{
dataflow_set_different_value = true;
--- 1318,1324 ----
return 0;
}
! if (variable_different_p (var1, var2, false))
{
dataflow_set_different_value = true;
*************** dataflow_set_different_2 (void **slot, v
*** 1342,1348 ****
#ifdef ENABLE_CHECKING
/* If both variables are defined they have been already checked for
equivalence. */
! if (variable_different_p (var1, var2))
abort ();
#endif
--- 1353,1359 ----
#ifdef ENABLE_CHECKING
/* If both variables are defined they have been already checked for
equivalence. */
! if (variable_different_p (var1, var2, false))
abort ();
#endif
*************** emit_notes_for_differences_1 (void **slo
*** 2286,2292 ****
empty_var->n_var_parts = 0;
variable_was_changed (empty_var, NULL);
}
! else if (variable_different_p (old_var, new_var))
{
variable_was_changed (new_var, NULL);
}
--- 2297,2303 ----
empty_var->n_var_parts = 0;
variable_was_changed (empty_var, NULL);
}
! else if (variable_different_p (old_var, new_var, true))
{
variable_was_changed (new_var, NULL);
}
More information about the Gcc-patches
mailing list