Skip ubsan internal fns in tail-merge
2016-03-07 Tom de Vries <tom@codesourcery.com>
* tree-ssa-tail-merge.c (merge_stmt_p): New function, factored out
of ...
(find_duplicate): ... here.
(merge_stmt_p): Return false for ubsan functions.
---
gcc/tree-ssa-tail-merge.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
@@ -1207,6 +1207,33 @@ gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse,
}
}
+/* Return true if STMT is allowed to be merged. */
+
+static bool
+merge_stmt_p (gimple *stmt)
+{
+ if (is_tm_ending (stmt))
+ return false;
+
+ if (is_gimple_call (stmt)
+ && gimple_call_internal_p (stmt))
+ switch (gimple_call_internal_fn (stmt))
+ {
+ 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:
+ return false;
+ default:
+ break;
+ }
+
+ return true;
+}
+
/* Determines whether BB1 and BB2 (members of same_succ) are duplicates. If so,
clusters them. */
@@ -1229,8 +1256,8 @@ find_duplicate (same_succ *same_succ, basic_block bb1, basic_block bb2)
/* 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 (!merge_stmt_p (stmt1)
+ || !merge_stmt_p (stmt2))
return;
if (!gimple_equal_p (same_succ, stmt1, stmt2))