This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Handle PTR + OFFSET in collect_points_to_info_r
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Sep 2004 18:36:20 -0400
- Subject: [PATCH] Handle PTR + OFFSET in collect_points_to_info_r
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
When collect_points_to_info_r looks at &x + 8,
most likely (always) both operands are POINTER_TYPE_P,
collect_points_to_info_r assumes that var points to either
x, or (void *) 8.
The following patch corrects it, ok to commit?
Bootstrapped/regtested on i386-redhat-linux.
2004-09-09 Jakub Jelinek <jakub@redhat.com>
* tree-ssa-alias.c (collect_points_to_info_r): Handle
pointing to PTR + OFFSET as PTR, not as pointing to PTR or pointing
to OFFSET.
--- gcc/tree-ssa-alias.c.jj 2004-08-31 13:56:01.000000000 +0200
+++ gcc/tree-ssa-alias.c 2004-09-09 19:42:11.058285500 +0200
@@ -1898,7 +1898,8 @@ collect_points_to_info_r (tree var, tree
/* Both operands may be of pointer type. FIXME: Shouldn't
we just expect PTR + OFFSET always? */
- if (POINTER_TYPE_P (TREE_TYPE (op0)))
+ if (POINTER_TYPE_P (TREE_TYPE (op0))
+ && TREE_CODE (op0) != INTEGER_CST)
{
if (TREE_CODE (op0) == SSA_NAME)
merge_pointed_to_info (ai, var, op0);
@@ -1908,7 +1909,8 @@ collect_points_to_info_r (tree var, tree
add_pointed_to_expr (var, op0);
}
- if (POINTER_TYPE_P (TREE_TYPE (op1)))
+ if (POINTER_TYPE_P (TREE_TYPE (op1))
+ && TREE_CODE (op0) != INTEGER_CST)
{
if (TREE_CODE (op1) == SSA_NAME)
merge_pointed_to_info (ai, var, op1);
@@ -1921,8 +1923,10 @@ collect_points_to_info_r (tree var, tree
/* Neither operand is a pointer? VAR can be pointing
anywhere. FIXME: Is this right? If we get here, we
found PTR = INT_CST + INT_CST. */
- if (!POINTER_TYPE_P (TREE_TYPE (op0))
- && !POINTER_TYPE_P (TREE_TYPE (op1)))
+ if (!(POINTER_TYPE_P (TREE_TYPE (op0))
+ && TREE_CODE (op0) != INTEGER_CST)
+ && !(POINTER_TYPE_P (TREE_TYPE (op1))
+ && TREE_CODE (op1) != INTEGER_CST))
add_pointed_to_expr (var, rhs);
}
Jakub