public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258]
@ 2023-02-22  9:12 Jakub Jelinek
  2023-02-22  9:52 ` Richard Biener
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2023-02-22  9:12 UTC (permalink / raw)
  To: Richard Biener, Jan Hubicka, Martin Jambor; +Cc: gcc-patches

Hi!

The following testcase ICEs because we still have some spots that
treat BUILT_IN_UNREACHABLE specially but not BUILT_IN_UNREACHABLE_TRAP
the same.

The following patch fixes that, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2023-02-22  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/106258
	* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee,
	cgraph_update_edges_for_call_stmt_node, cgraph_node::verify_node):
	Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE.
	* cgraphclones.cc (cgraph_node::create_clone): Likewise.

	* g++.dg/ipa/pr106258.C: New test.

--- gcc/cgraph.cc.jj	2023-02-07 10:33:46.027107080 +0100
+++ gcc/cgraph.cc	2023-02-21 14:57:10.405454504 +0100
@@ -1548,7 +1548,8 @@ cgraph_edge::redirect_call_stmt_to_calle
   else
     {
       if (flag_checking
-	  && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
+	  && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)
+	  && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE_TRAP))
 	ipa_verify_edge_has_no_modifications (e);
       new_stmt = e->call_stmt;
       gimple_call_set_fndecl (new_stmt, e->callee->decl);
@@ -1634,7 +1635,9 @@ cgraph_update_edges_for_call_stmt_node (
 	{
 	  /* Keep calls marked as dead dead.  */
 	  if (new_stmt && is_gimple_call (new_stmt) && e->callee
-	      && fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
+	      && (fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)
+		  || fndecl_built_in_p (e->callee->decl,
+					BUILT_IN_UNREACHABLE_TRAP)))
 	    {
 	      cgraph_edge::set_call_stmt (node->get_edge (old_stmt),
 					  as_a <gcall *> (new_stmt));
@@ -3598,7 +3601,9 @@ cgraph_node::verify_node (void)
 	  /* Optimized out calls are redirected to __builtin_unreachable.  */
 	  && (e->count.nonzero_p ()
 	      || ! e->callee->decl
-	      || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
+	      || !(fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)
+		   || fndecl_built_in_p (e->callee->decl,
+					 BUILT_IN_UNREACHABLE_TRAP)))
 	  && count
 	      == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
 	  && (!e->count.ipa_p ()
--- gcc/cgraphclones.cc.jj	2023-01-02 09:32:44.706962765 +0100
+++ gcc/cgraphclones.cc	2023-02-21 14:58:11.619568895 +0100
@@ -425,7 +425,9 @@ cgraph_node::create_clone (tree new_decl
 	 version.  The only exception is when the edge was proved to
 	 be unreachable during the cloning procedure.  */
       if (!e->callee
-	  || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
+	  || !(fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)
+	       || fndecl_built_in_p (e->callee->decl,
+				     BUILT_IN_UNREACHABLE_TRAP)))
         e->redirect_callee_duplicating_thunks (new_node);
     }
   new_node->expand_all_artificial_thunks ();
--- gcc/testsuite/g++.dg/ipa/pr106258.C.jj	2023-02-21 15:02:17.251015237 +0100
+++ gcc/testsuite/g++.dg/ipa/pr106258.C	2023-02-21 15:02:12.255087511 +0100
@@ -0,0 +1,5 @@
+// PR middle-end/106258
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -funreachable-traps" }
+
+#include "ipa-sra-4.C"

	Jakub


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-02-23 10:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22  9:12 [PATCH] cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258] Jakub Jelinek
2023-02-22  9:52 ` Richard Biener
2023-02-22 11:04   ` [PATCH] tree: Add 3 argument fndecl_built_in_p Jakub Jelinek
2023-02-22 11:43     ` Richard Biener
2023-02-22 12:16       ` Jonathan Wakely
2023-02-22 12:35         ` Jonathan Wakely
2023-02-22 18:33           ` [PATCH] tree, v2: " Jakub Jelinek
2023-02-22 18:46             ` Richard Biener
2023-02-23  6:56               ` [PATCH] ipa-prop: Fix another case of missing BUILT_IN_UNREACHABLE_TRAP handling [PR106258] Jakub Jelinek
2023-02-23 10:33                 ` Richard Biener
2023-02-22 12:49         ` [PATCH] tree: Add 3 argument fndecl_built_in_p Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).