public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: gcc-patches@gcc.gnu.org, mjambor@suse.de
Subject: Re: Fix wrong code issues with ipa-sra
Date: Sun, 22 Jan 2023 00:13:45 +0300 (MSK)	[thread overview]
Message-ID: <f00b4f43-8c85-35c2-8eb1-40118d7b5bbc@ispras.ru> (raw)
In-Reply-To: <Y8WG3g+bAIynpiHC@kam.mff.cuni.cz>

Hello,

Coverity flagged a real issue in this patch:

On Mon, 16 Jan 2023, Jan Hubicka via Gcc-patches wrote:
> --- a/gcc/ipa-utils.cc
> +++ b/gcc/ipa-utils.cc
[...]
> +bitmap
> +find_always_executed_bbs (function *fun, bool assume_return_or_eh)
> +{
> +  auto_vec<basic_block, 20> stack;
> +  auto_vec<basic_block, 20> terminating_bbs;
> +  hash_set<basic_block> visited;
> +  edge e;
> +  edge_iterator ei;
> +
> +  /* First walk all BBs reachable from entry stopping on statements that may
> +     terminate execution.  Everything past this statement is not going to be executed
> +     each invocation.  */
> +  stack.safe_push (ENTRY_BLOCK_PTR_FOR_FN (fun));
> +  while (!stack.is_empty ())
> +    {
> +      basic_block bb = stack.pop ();
> +      bool found = false, found_exit = false;
> +      if (!assume_return_or_eh
> +	  && (EDGE_COUNT (bb->succs) == 0 || (bb->flags & BB_IRREDUCIBLE_LOOP)))
> +	found = true;
> +      FOR_EACH_EDGE (e, ei, bb->succs)
> +	{
> +	  if (e->dest == EXIT_BLOCK_PTR_FOR_FN (fun))
> +	    {
> +	      found_exit = true;
> +	      break;
> +	    }
> +	  /* Watch for infinite loops.  */
> +	  if (!found && (assume_return_or_eh & EDGE_DFS_BACK)
                                             ^^^^^^^^^^^^^^^
This bitwise 'and' always evaluates to zero, making the entire clause always-false.

Alexander

  reply	other threads:[~2023-01-21 21:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 17:18 Jan Hubicka
2023-01-21 21:13 ` Alexander Monakov [this message]
2023-01-30 14:44   ` Jan Hubicka

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=f00b4f43-8c85-35c2-8eb1-40118d7b5bbc@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mjambor@suse.de \
    /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).