diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index 5f72ace9b57..b810237c919 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -3248,9 +3248,11 @@ cgraph_edge::verify_corresponds_to_fndecl (tree decl) node = node->ultimate_alias_target (); /* Optimizers can redirect unreachable calls or calls triggering undefined - behavior to builtin_unreachable. */ + behavior to __builtin_unreachable or __builtin_trap. */ - if (fndecl_built_in_p (callee->decl, BUILT_IN_UNREACHABLE)) + 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)) return false; if (callee->former_clone_of != node->decl diff --git a/gcc/testsuite/gcc.dg/pr106061.c b/gcc/testsuite/gcc.dg/pr106061.c new file mode 100644 index 00000000000..bba8d29bf47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106061.c @@ -0,0 +1,18 @@ +/* PR ipa/106061 */ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +extern void foo (void); + +inline void +bar (int x) +{ + if (x) + foo (); +} + +void +baz (void) +{ + bar (0); +}