public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jan Hubicka <jh@suse.cz>, Martin Jambor <mjambor@suse.cz>,
	 gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258]
Date: Wed, 22 Feb 2023 09:52:06 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2302220952010.27913@jbgna.fhfr.qr> (raw)
In-Reply-To: <Y/XclksRe7Btwfim@tucnak>

On Wed, 22 Feb 2023, Jakub Jelinek wrote:

> 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?

OK.

> 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
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

  reply	other threads:[~2023-02-22  9:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22  9:12 Jakub Jelinek
2023-02-22  9:52 ` Richard Biener [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.YFH.7.77.849.2302220952010.27913@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jh@suse.cz \
    --cc=mjambor@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).