]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Skip ubsan/asan internal fns with different location in tail-merge
authorTom de Vries <tom@codesourcery.com>
Mon, 7 Mar 2016 14:50:13 +0000 (14:50 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 7 Mar 2016 14:50:13 +0000 (14:50 +0000)
2016-03-07  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/70116
* tree-ssa-tail-merge.c (merge_stmts_p): New function, handling
is_tm_ending stmts and ubsan/asan internal functions.
(find_duplicate): Use it.  Don't test is_tm_ending here.

From-SVN: r234029

gcc/ChangeLog
gcc/tree-ssa-tail-merge.c

index 04fb3361f41ac91b6b4dbcb072b7b344ef8269fa..176ef4e16093e85cc431a33b9d54da7e627901bf 100644 (file)
@@ -1,3 +1,10 @@
+2016-03-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/70116
+       * tree-ssa-tail-merge.c (merge_stmts_p): New function, handling
+       is_tm_ending stmts and ubsan/asan internal functions.
+       (find_duplicate): Use it.  Don't test is_tm_ending here.
+
 2016-03-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/70115
index 5d327902c537fd9594154e0f3e5a457ed6d096af..e95879fb8aa07a936be1d1c8b94aaff911c4971b 100644 (file)
@@ -1207,6 +1207,42 @@ gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse,
     }
 }
 
+/* Return true if equal (in the sense of gimple_equal_p) statements STMT1 and
+   STMT2 are allowed to be merged.  */
+
+static bool
+merge_stmts_p (gimple *stmt1, gimple *stmt2)
+{
+  /* What could be better than this here is to blacklist the bb
+     containing the stmt, when encountering the stmt f.i. in
+     same_succ_hash.  */
+  if (is_tm_ending (stmt1))
+    return false;
+
+  if (is_gimple_call (stmt1)
+      && gimple_call_internal_p (stmt1))
+    switch (gimple_call_internal_fn (stmt1))
+      {
+      case IFN_UBSAN_NULL:
+      case IFN_UBSAN_BOUNDS:
+      case IFN_UBSAN_VPTR:
+      case IFN_UBSAN_CHECK_ADD:
+      case IFN_UBSAN_CHECK_SUB:
+      case IFN_UBSAN_CHECK_MUL:
+      case IFN_UBSAN_OBJECT_SIZE:
+      case IFN_ASAN_CHECK:
+       /* For these internal functions, gimple_location is an implicit
+          parameter, which will be used explicitly after expansion.
+          Merging these statements may cause confusing line numbers in
+          sanitizer messages.  */
+       return gimple_location (stmt1) == gimple_location (stmt2);
+      default:
+       break;
+      }
+
+  return true;
+}
+
 /* Determines whether BB1 and BB2 (members of same_succ) are duplicates.  If so,
    clusters them.  */
 
@@ -1226,14 +1262,10 @@ find_duplicate (same_succ *same_succ, basic_block bb1, basic_block bb2)
       gimple *stmt1 = gsi_stmt (gsi1);
       gimple *stmt2 = gsi_stmt (gsi2);
 
-      /* What could be better than this here is to blacklist the bb
-        containing the stmt, when encountering the stmt f.i. in
-        same_succ_hash.  */
-      if (is_tm_ending (stmt1)
-         || is_tm_ending (stmt2))
+      if (!gimple_equal_p (same_succ, stmt1, stmt2))
        return;
 
-      if (!gimple_equal_p (same_succ, stmt1, stmt2))
+      if (!merge_stmts_p (stmt1, stmt2))
        return;
 
       gsi_prev_nondebug (&gsi1);