}
if (e->has_callback
- && !callback_is_special_cased (e->callee->decl, e->call_stmt))
+ && !callback_is_special_cased (e->callee->decl, e->call_stmt)
+ && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
{
int ncallbacks = 0;
int nfound_edges = 0;
}
}
+ if (e->has_callback
+ && fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
+ for (cgraph_edge *cbe = e->first_callback_edge (); cbe;
+ cbe = cbe->next_callback_edge ())
+ if (!fndecl_built_in_p (cbe->callee->decl, BUILT_IN_UNREACHABLE))
+ error ("callback-carrying edge is pointing towards "
+ "__builtin_unreachable, but its callback edge %s -> %s "
+ "is not",
+ cbe->caller->name (), cbe->callee->name ());
+
if (!e->aux && !e->speculative && !e->callback && !e->has_callback)
{
error ("edge %s->%s has no corresponding call_stmt",
if (callee)
callee->remove_symbol_and_inline_clones ();
if (e->has_callback)
- e->purge_callback_edges ();
+ for (cgraph_edge *cbe = e->first_callback_edge (); cbe;
+ cbe = cbe->next_callback_edge ())
+ /* If the carrying edge is unreachable, so are the callback calls. */
+ redirect_to_unreachable (cbe);
return e;
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target fopenmp } */
+/* { dg-options "-O2 -fopenmp" } */
+
+int a, b, c;
+
+static void
+foo (int g)
+{
+ int f = c ? c : 2;
+ if (c)
+ b = 3;
+ if (!g)
+ for (int d = 0; d < f; ++d)
+#pragma omp parallel
+ while (a)
+ ;
+}
+
+void
+bar (void)
+{
+ foo (1);
+}