public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: gcc-patches@gcc.gnu.org, "H.J. Lu" <hjl.tools@gmail.com>,
	Richard Biener <richard.guenther@gmail.com>,
	Arnaud Charlet <charlet@adacore.com>
Subject: Re: Fix lto-symtab ICE during Ada LTO bootstrap
Date: Mon, 21 Dec 2015 15:16:00 -0000	[thread overview]
Message-ID: <2335219.HdMfxlLlst@polaris> (raw)
In-Reply-To: <20151221141944.GB10803@kam.mff.cuni.cz>

[-- Attachment #1: Type: text/plain, Size: 2530 bytes --]

> I suppose the CFG verifier should also catch this.  I wonder how this can
> lead to wrong code as opossed to infinite loop?
> I can imagine DCE being confused about non-control-flow stmt and conclude
> the abnormal path as the path leaving the loop.  I will look into the
> testcase more.

   <bb 4063>:
   # DEBUG id => e_186
   _11422 = atree__unchecked_access__node4.localalias.3007 (e_186);
 
   <bb 4064>:
   # DEBUG id => NULL
   # DEBUG n => _11422
   # DEBUG n => NULL
   if (_11422 == 0)
     goto <bb 4097> (<L255>);
   else
     goto <bb 4065>;

The next block is:

  <bb 4065>:
  # DEBUG id => e_186
  goto <bb 4046>;

and has the stalled ABNORMAL flag.  This causes the latch edge to be split.

When the PHI node consuming _11422 is processed:

processing: e_186 = PHI <e_7741(4046), _11422(4164)>

the following code is invoked:

          if (aggressive && !degenerate_phi_p (stmt))
            {
              for (k = 0; k < gimple_phi_num_args (stmt); k++)
                {
                  basic_block arg_bb = gimple_phi_arg_edge (phi, k)->src;

          if (gimple_bb (stmt)
              != get_immediate_dominator (CDI_POST_DOMINATORS, arg_bb))
                    {
                      if (!bitmap_bit_p (last_stmt_necessary, arg_bb->index))
                        mark_last_stmt_necessary (arg_bb);
                    }
                  else if (arg_bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
                           && !bitmap_bit_p (visited_control_parents,
                                         arg_bb->index))
                    mark_control_dependent_edges_necessary (arg_bb, true);
                }
            }

arg_bb is the immediate postdominator of gimple_bb (stmt) so the first 
condition is false.  And the second condition is also false because arg_bb was 
already marked in visited_control_parents from:

      FOR_EACH_LOOP (loop, 0)
        if (!finite_loop_p (loop))
          {
            if (dump_file)
             fprintf (dump_file, "can not prove finiteness of loop %i\n", 
loop->num);
            mark_control_dependent_edges_necessary (loop->latch, false);
          }

I'm not quite sure where the logic goes wrong, but the comment just above the 
first quoted block of code makes one think it is a bit fragile.

In any case, the fixlet I posted was slightly off, so here is the patch I have 
installed as obvious after testing on x86-64/Linux.


	PR tree-optimization/65337
	* tree-ssa-pre.c (eliminate): Also clean up abnormal edges if need be.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 471 bytes --]

Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c	(revision 231856)
+++ tree-ssa-pre.c	(working copy)
@@ -4499,6 +4499,8 @@ eliminate (bool do_pre)
 	  unlink_stmt_vdef (stmt);
 	  if (gsi_remove (&gsi, true))
 	    bitmap_set_bit (need_eh_cleanup, bb->index);
+	  if (is_gimple_call (stmt) && stmt_can_make_abnormal_goto (stmt))
+	    bitmap_set_bit (need_ab_cleanup, bb->index);
 	  release_defs (stmt);
 	}
 

  reply	other threads:[~2015-12-21 15:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21 18:35 Jan Hubicka
2015-11-22 14:46 ` Eric Botcazou
2015-11-22 15:17   ` Arnaud Charlet
2015-11-23  1:24     ` Jan Hubicka
2015-11-23  9:59       ` Arnaud Charlet
2015-11-23 11:13         ` Eric Botcazou
2015-11-23 11:24           ` Arnaud Charlet
2015-11-23 12:00             ` Eric Botcazou
2015-11-23 13:35               ` Richard Biener
2015-11-23 16:05                 ` Eric Botcazou
2015-11-23 16:17                   ` H.J. Lu
2015-11-23 16:26                     ` Eric Botcazou
2015-11-23 16:31                       ` Arnaud Charlet
2015-11-23 19:05                       ` Jan Hubicka
2015-11-23 22:29                         ` Eric Botcazou
2015-11-23 22:53                           ` Jan Hubicka
2015-11-23 23:09                             ` Jan Hubicka
2015-12-20  6:54                         ` Jan Hubicka
2015-12-20  8:14                           ` Eric Botcazou
2015-12-20 22:20                         ` Eric Botcazou
2015-12-21 10:20                           ` Eric Botcazou
2015-12-21 14:19                             ` Jan Hubicka
2015-12-21 15:16                               ` Eric Botcazou [this message]
2015-12-21 14:20                             ` Jan Hubicka
2015-11-22 18:49   ` 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=2335219.HdMfxlLlst@polaris \
    --to=ebotcazou@adacore.com \
    --cc=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.com \
    /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).