switch (DECL_FUNCTION_CODE (callee))
{
case BUILT_IN_UNREACHABLE:
+ case BUILT_IN_UNREACHABLE_TRAP:
case BUILT_IN_TRAP:
/* Don't instrument these. */
return false;
|| !DECL_P (*anode)
|| DECL_BUILT_IN_CLASS (*anode) != BUILT_IN_NORMAL
|| (DECL_FUNCTION_CODE (*anode) != BUILT_IN_UNREACHABLE
+ && DECL_FUNCTION_CODE (*anode) != BUILT_IN_UNREACHABLE_TRAP
&& (DECL_FUNCTION_CODE (*anode)
!= BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE)))
{
break;
case BUILT_IN_TRAP:
+ case BUILT_IN_UNREACHABLE_TRAP:
expand_builtin_trap ();
return const0_rtx;
case BUILT_IN_VA_ARG_PACK_LEN:
case BUILT_IN_VA_COPY:
case BUILT_IN_TRAP:
+ case BUILT_IN_UNREACHABLE_TRAP:
case BUILT_IN_SAVEREGS:
case BUILT_IN_POPCOUNTL:
case BUILT_IN_POPCOUNTLL:
DEF_EXT_LIB_BUILTIN (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_NOTHROW_3_4)
DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0)
DEF_GCC_BUILTIN (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST)
+DEF_GCC_BUILTIN (BUILT_IN_UNREACHABLE_TRAP, "unreachable trap", BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST)
DEF_GCC_BUILTIN (BUILT_IN_UNREACHABLE, "unreachable", BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST)
DEF_GCC_BUILTIN (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", BT_FN_VOID_PTR, ATTR_NULL)
node = node->ultimate_alias_target ();
/* Optimizers can redirect unreachable calls or calls triggering undefined
- behavior to __builtin_unreachable or __builtin_trap. */
+ behavior to __builtin_unreachable or __builtin_unreachable trap. */
if (fndecl_built_in_p (callee->decl, BUILT_IN_NORMAL)
&& (DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE
- || DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_TRAP))
+ || DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE_TRAP))
return false;
if (callee->former_clone_of != node->decl
{
tree data = NULL_TREE;
tree fn = sanitize_unreachable_fn (&data, loc);
- 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);
- }
+ gcall *g = gimple_build_call (fn, data != NULL_TREE, data);
gimple_call_set_ctrl_altering (g, true);
gimple_set_location (g, loc);
return g;
}
void
-expand_TRAP (internal_fn, gcall *)
-{
- expand_builtin_trap ();
-}
-
-void
expand_ASSUME (internal_fn, gcall *)
{
}
/* <=> 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 | ECF_LOOPING_CONST_OR_PURE,
- NULL)
-
/* [[assume (cond)]]. */
DEF_INTERNAL_FN (ASSUME, ECF_CONST | ECF_LEAF | ECF_NOTHROW
| ECF_LOOPING_CONST_OR_PURE, NULL)
unsigned int i;
bool final;
- if (fndecl_built_in_p (n->decl, BUILT_IN_UNREACHABLE)
- || fndecl_built_in_p (n->decl, BUILT_IN_TRAP))
+ if (fndecl_built_in_p (n->decl, BUILT_IN_NORMAL)
+ && (DECL_FUNCTION_CODE (n->decl) == BUILT_IN_UNREACHABLE
+ || DECL_FUNCTION_CODE (n->decl) == BUILT_IN_TRAP
+ || DECL_FUNCTION_CODE (n->decl) == BUILT_IN_UNREACHABLE_TRAP))
return true;
if (is_cxa_pure_virtual_p (n->decl))
--- /dev/null
+/* PR ipa/107300 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fipa-cp-clone -funreachable-traps -fno-inline" } */
+
+void
+bar (int x, int y)
+{
+ if (x)
+ __builtin_unreachable ();
+
+ if (y)
+ __builtin_abort ();
+}
+
+void
+foo (void)
+{
+ bar (0, 0);
+}
switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_UNREACHABLE:
+ case BUILT_IN_UNREACHABLE_TRAP:
case BUILT_IN_TRAP:
if (gimple_call_num_args (stmt) > 0)
{
&& ((LOCATION_LOCUS (gimple_location (last))
== BUILTINS_LOCATION
&& (gimple_call_builtin_p (last, BUILT_IN_UNREACHABLE)
+ || gimple_call_builtin_p (last,
+ BUILT_IN_UNREACHABLE_TRAP)
|| gimple_call_builtin_p (last, BUILT_IN_TRAP)))
|| gimple_call_builtin_p (last, ubsan_missing_ret)))
{
if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE)
|| !builtin_decl_explicit_p (BUILT_IN_TRAP)
+ || !builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP)
|| !builtin_decl_explicit_p (BUILT_IN_ABORT))
{
ftype = build_function_type (void_type_node, void_list_node);
"__builtin_unreachable",
ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
| ECF_CONST | ECF_COLD);
+ if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP))
+ local_define_builtin ("__builtin_unreachable trap", ftype,
+ BUILT_IN_UNREACHABLE_TRAP,
+ "__builtin_unreachable trap",
+ ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
+ | ECF_CONST | ECF_COLD);
if (!builtin_decl_explicit_p (BUILT_IN_ABORT))
local_define_builtin ("__builtin_abort", ftype, BUILT_IN_ABORT,
"abort",
if (sanitize_flags_p (SANITIZE_UNREACHABLE)
? (flag_sanitize_trap & SANITIZE_UNREACHABLE)
: flag_unreachable_traps)
- fncode = BUILT_IN_TRAP;
+ fncode = BUILT_IN_UNREACHABLE_TRAP;
/* For non-trapping sanitize, we will rewrite __builtin_unreachable () later,
in the sanopt pass. */