This is the mail archive of the
mailing list for the GCC project.
[PATCH] Fix -fcompare-debug issue in ivopts (PR debug/46150)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 11 Nov 2010 00:29:55 +0100
- Subject: [PATCH] Fix -fcompare-debug issue in ivopts (PR debug/46150)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
As explained in the PR, the testcase from the PR (which I haven't managed
to reduce enough even after 5 days of delta treatments) results in
-fcompare-debug failure, starting in ivopts.
The problem is that ivopts uses a iterative_hash_expr as hash functions
for expressions (which uses TYPE_UID/DECL_UID, so is not identical between
-g/-g0) together with the very lax operand_equal_p predicate as equality
function. Depending on how things end up layed out in the hash table (which
depends on the exact hash values of course and thus on -g/-g0) it can or
doesn't call operand_equal_p on expressions which have different hash value
and just happened to have hash % size the same (or be somewhere where it
searches) and it can sometimes succeed. If it succeeds for -g and not for
-g0 or vice versa, it affects ivopts behavior and results in -fcompare-debug
Ideally we'd either have some less lax function that would basically compare
what is iterative_hash_expr hashing, or have a hash function that would
match operand_equal_p, but for the time being I think the following patch
should be enough (and certainly fixes the testcase).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2010-11-10 Jakub Jelinek <email@example.com>
* tree-ssa-loop-ivopts.c (htab_inv_expr_eq): Don't return
true if expr1->hash != expr2->hash.
--- gcc/tree-ssa-loop-ivopts.c.jj 2010-11-09 13:58:30.000000000 +0100
+++ gcc/tree-ssa-loop-ivopts.c 2010-11-10 21:36:54.000000000 +0100
@@ -834,7 +834,8 @@ htab_inv_expr_eq (const void *ent1, cons
const struct iv_inv_expr_ent *expr2 =
(const struct iv_inv_expr_ent *)ent2;
- return operand_equal_p (expr1->expr, expr2->expr, 0);
+ return expr1->hash == expr2->hash
+ && operand_equal_p (expr1->expr, expr2->expr, 0);
/* Hash function for loop invariant expressions. */