{
tree data = NULL_TREE;
tree fn = sanitize_unreachable_fn (&data, loc);
- gcall *g = gimple_build_call (fn, data != NULL_TREE, data);
+ gcall *g;
+ if (DECL_FUNCTION_CODE (fn) != BUILT_IN_TRAP)
+ g = gimple_build_call (fn, data != NULL_TREE, data);
+ else
+ {
+ /* Instead of __builtin_trap use .TRAP, so that it doesn't
+ need vops. */
+ gcc_checking_assert (data == NULL_TREE);
+ g = gimple_build_call_internal (IFN_TRAP, 0);
+ }
gimple_set_location (g, loc);
return g;
}
if (!rtx_equal_p (target, ops[0].value))
emit_move_insn (target, ops[0].value);
}
+
+void
+expand_TRAP (internal_fn, gcall *)
+{
+ expand_builtin_trap ();
+}
/* <=> optimization. */
DEF_INTERNAL_FN (SPACESHIP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
+/* __builtin_trap created from/for __builtin_unreachable. */
+DEF_INTERNAL_FN (TRAP, ECF_CONST | ECF_LEAF | ECF_NORETURN
+ | ECF_NOTHROW | ECF_COLD, NULL)
+
#undef DEF_INTERNAL_INT_FN
#undef DEF_INTERNAL_FLT_FN
#undef DEF_INTERNAL_FLT_FLOATN_FN
extern void expand_PHI (internal_fn, gcall *);
extern void expand_SHUFFLEVECTOR (internal_fn, gcall *);
extern void expand_SPACESHIP (internal_fn, gcall *);
+extern void expand_TRAP (internal_fn, gcall *);
extern bool vectorized_internal_fn_supported_p (internal_fn, tree);
--- /dev/null
+/* PR tree-optimization/106099 */
+/* { dg-do compile } */
+/* { dg-options "-O -fsanitize=unreachable -fsanitize-undefined-trap-on-error -fno-tree-ccp -fno-tree-dominator-opts" } */
+
+void
+foo (void)
+{
+ for (unsigned i = 0; i == 0; i++)
+ ;
+}