]> gcc.gnu.org Git - gcc.git/commitdiff
re PR sanitizer/70683 (-fcompare-debug bug with -fsanitize=address)
authorJakub Jelinek <jakub@redhat.com>
Wed, 27 Apr 2016 13:29:34 +0000 (15:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 27 Apr 2016 13:29:34 +0000 (15:29 +0200)
PR sanitizer/70683
* tree-core.h (enum operand_equal_flag): Add OEP_NO_HASH_CHECK.
* fold-const.c (operand_equal_p): If flag_checking and
OEP_NO_HASH_CHECK is not set in flag, recurse with OEP_NO_HASH_CHECK
and if it returns non-zero, assert iterative_hash_expr on both
args is the same.

From-SVN: r235507

gcc/ChangeLog
gcc/fold-const.c
gcc/tree-core.h

index f99b0c3aae4b620eb7bb5f3d59a709343e73831c..6d26cb00a95d013e7bac5457fb31ea65a7a723df 100644 (file)
@@ -1,3 +1,12 @@
+2016-04-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/70683
+       * tree-core.h (enum operand_equal_flag): Add OEP_NO_HASH_CHECK.
+       * fold-const.c (operand_equal_p): If flag_checking and
+       OEP_NO_HASH_CHECK is not set in flag, recurse with OEP_NO_HASH_CHECK
+       and if it returns non-zero, assert iterative_hash_expr on both
+       args is the same.
+
 2016-04-27  Bernd Schmidt  <bschmidt@redhat.com>
 
        * doc/invoke.texi (-frename-registers): Also enabled at -Os.
index 1ce66e7d090adf55ebf8d92005def641788fa4b1..7fc23c6c3d52e17d4ed99fb1612eb65ebbc6af8c 100644 (file)
@@ -2749,6 +2749,25 @@ combine_comparisons (location_t loc,
 int
 operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
 {
+  /* When checking, verify at the outermost operand_equal_p call that
+     if operand_equal_p returns non-zero then ARG0 and ARG1 has the same
+     hash value.  */
+  if (flag_checking && !(flags & OEP_NO_HASH_CHECK))
+    {
+      if (operand_equal_p (arg0, arg1, flags | OEP_NO_HASH_CHECK))
+       {
+         inchash::hash hstate0 (0), hstate1 (0);
+         inchash::add_expr (arg0, hstate0, flags);
+         inchash::add_expr (arg1, hstate1, flags);
+         hashval_t h0 = hstate0.end ();
+         hashval_t h1 = hstate1.end ();
+         gcc_assert (h0 == h1);
+         return 1;
+       }
+      else
+       return 0;
+    }
+
   /* If either is ERROR_MARK, they aren't equal.  */
   if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK
       || TREE_TYPE (arg0) == error_mark_node
index 0d48ff59d52392ac004c14842bc46ad2bf491ce1..6d573d7b6d290874945eff0e18249b0895a84525 100644 (file)
@@ -765,7 +765,9 @@ enum operand_equal_flag {
   OEP_ONLY_CONST = 1,
   OEP_PURE_SAME = 2,
   OEP_MATCH_SIDE_EFFECTS = 4,
-  OEP_ADDRESS_OF = 8
+  OEP_ADDRESS_OF = 8,
+  /* Internal within operand_equal_p:  */
+  OEP_NO_HASH_CHECK = 16
 };
 
 /* Enum and arrays used for tree allocation stats.
This page took 0.094544 seconds and 5 git commands to generate.