This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][alias-improvements] Fix alias-2.c regression
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 11 Jan 2009 23:25:10 +0100 (CET)
- Subject: [PATCH][alias-improvements] Fix alias-2.c regression
Use ipa-reference information to disambiguate against global statics.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
branch.
Richard.
2009-01-11 Richard Guenther <rguenther@suse.de>
* tree-ssa-alias.c (ref_may_used_by_call_p): Use
ipa_reference_get_not_read_global to disambiguate against
global statics.
(call_may_clobber_ref_p): Same with
ipa_reference_get_not_written_global.
Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c (revision 143275)
--- gcc/tree-ssa-alias.c (working copy)
*************** debug_points_to_info_for (tree var)
*** 362,368 ****
otherwise return false. */
static bool
! ref_may_used_by_call_p (gimple call ATTRIBUTE_UNUSED, tree ref)
{
tree base = get_base_address (ref);
unsigned i;
--- 362,368 ----
otherwise return false. */
static bool
! ref_may_used_by_call_p (gimple call, tree ref)
{
tree base = get_base_address (ref);
unsigned i;
*************** ref_may_used_by_call_p (gimple call ATTR
*** 374,379 ****
--- 374,395 ----
|| !DECL_P (base))
return true;
+ /* Check if base is a global static variable that is not read
+ by the function. */
+ if (TREE_CODE (base) == VAR_DECL
+ && TREE_STATIC (base)
+ && !TREE_PUBLIC (base))
+ {
+ tree callee = gimple_call_fndecl (call);
+ bitmap not_read;
+
+ if (callee != NULL_TREE
+ && (not_read
+ = ipa_reference_get_not_read_global (cgraph_node (callee)))
+ && bitmap_bit_p (not_read, DECL_UID (base)))
+ return false;
+ }
+
/* If the base variable is call-used then it may be used. */
if (is_call_used (base))
return true;
*************** call_may_clobber_ref_p (gimple call, tre
*** 448,453 ****
--- 464,485 ----
|| CONSTANT_CLASS_P (base))
return false;
+ /* Check if base is a global static variable that is not written
+ by the function. */
+ if (TREE_CODE (base) == VAR_DECL
+ && TREE_STATIC (base)
+ && !TREE_PUBLIC (base))
+ {
+ tree callee = gimple_call_fndecl (call);
+ bitmap not_written;
+
+ if (callee != NULL_TREE
+ && (not_written
+ = ipa_reference_get_not_written_global (cgraph_node (callee)))
+ && bitmap_bit_p (not_written, DECL_UID (base)))
+ return false;
+ }
+
if (DECL_P (base))
return is_call_clobbered (base);