[PATCH] Fix PR38051, alias partitioning related problem
Richard Guenther
rguenther@suse.de
Mon Nov 17 20:41:00 GMT 2008
On Sat, 15 Nov 2008, Richard Guenther wrote:
>
> When partitioning partitions a variable in a second alias pass we
> miss to consider that variable as written to because we ask the
> stored_syms bitmap which only contains the MPT. This causes us
> to disregard the variable for conflicts.
>
> Fixed with the following - we can just look up the LHS decl ourselves.
> Memory tags are marked as written by the pointer setup code, calls
> and asms are handled by the fact that when we check the written
> variables we also check the call clobber set.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>
> This problem is latent on the branch, but as a backport is non-trivial
> I will not do it at this point.
PR38169 and some backports made it necessary that I fix this for the
branch as well. So here's the backport.
Bootstrapped and tested on x86_64-unknown-linux-gnu. I'll give this
more testing before applying it.
Richard.
2008-11-17 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38051
* tree-ssa-structalias.c (update_alias_info): Manually find
written variables.
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c (revision 141900)
--- gcc/tree-ssa-structalias.c (working copy)
*************** update_alias_info (tree stmt, struct ali
*** 3467,3472 ****
--- 3467,3495 ----
mem_ref_stats->num_mem_stmts++;
+ /* Add all decls written to to the list of written variables. */
+ if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
+ && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) != SSA_NAME)
+ {
+ tree lhs = GIMPLE_STMT_OPERAND (stmt, 0);
+ while (handled_component_p (lhs))
+ lhs = TREE_OPERAND (lhs, 0);
+ if (DECL_P (lhs))
+ {
+ subvar_t svars;
+ if (var_can_have_subvars (lhs)
+ && (svars = get_subvars_for_var (lhs)))
+ {
+ unsigned int i;
+ tree subvar;
+ for (i = 0; VEC_iterate (tree, svars, i, subvar); ++i)
+ pointer_set_insert (ai->written_vars, subvar);
+ }
+ else
+ pointer_set_insert (ai->written_vars, lhs);
+ }
+ }
+
/* Notice that we only update memory reference stats for symbols
loaded and stored by the statement if the statement does not
contain pointer dereferences and it is not a call/asm site.
*************** update_alias_info (tree stmt, struct ali
*** 3489,3513 ****
dereferences (e.g., MEMORY_VAR = *PTR) or if a call site has
memory symbols in its argument list, but these cases do not
occur so frequently as to constitute a serious problem. */
- if (STORED_SYMS (stmt))
- EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
- {
- tree sym = referenced_var (i);
- pointer_set_insert (ai->written_vars, sym);
- if (!stmt_dereferences_ptr_p
- && stmt_escape_type != ESCAPE_TO_CALL
- && stmt_escape_type != ESCAPE_TO_PURE_CONST
- && stmt_escape_type != ESCAPE_TO_ASM)
- update_mem_sym_stats_from_stmt (sym, stmt, 0, 1);
- }
-
if (!stmt_dereferences_ptr_p
- && LOADED_SYMS (stmt)
&& stmt_escape_type != ESCAPE_TO_CALL
&& stmt_escape_type != ESCAPE_TO_PURE_CONST
&& stmt_escape_type != ESCAPE_TO_ASM)
! EXECUTE_IF_SET_IN_BITMAP (LOADED_SYMS (stmt), 0, i, bi)
! update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 1, 0);
}
}
--- 3512,3530 ----
dereferences (e.g., MEMORY_VAR = *PTR) or if a call site has
memory symbols in its argument list, but these cases do not
occur so frequently as to constitute a serious problem. */
if (!stmt_dereferences_ptr_p
&& stmt_escape_type != ESCAPE_TO_CALL
&& stmt_escape_type != ESCAPE_TO_PURE_CONST
&& stmt_escape_type != ESCAPE_TO_ASM)
! {
! if (STORED_SYMS (stmt))
! EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
! update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 0, 1);
!
! if (LOADED_SYMS (stmt))
! EXECUTE_IF_SET_IN_BITMAP (LOADED_SYMS (stmt), 0, i, bi)
! update_mem_sym_stats_from_stmt (referenced_var (i), stmt, 1, 0);
! }
}
}
More information about the Gcc-patches
mailing list