/* Iterator routines for GIMPLE statements.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldy@quesejoda.com>
This file is part of GCC.
if (remove_permanently)
{
+ if (gimple_debug_nonbind_marker_p (stmt))
+ /* We don't need this to be exact, but try to keep it at least
+ close. */
+ cfun->debug_marker_count--;
require_eh_edge_purge = remove_stmt_from_eh_lp (stmt);
gimple_remove_stmt_histograms (cfun, stmt);
}
return i;
}
+/* Get an iterator for STMT, which is known to belong to SEQ. This is
+ equivalent to starting at the beginning of SEQ and searching forward
+ until STMT is found. */
+
+gimple_stmt_iterator
+gsi_for_stmt (gimple *stmt, gimple_seq *seq)
+{
+ gimple_stmt_iterator i = gsi_start_1 (seq);
+ i.ptr = stmt;
+ return i;
+}
+
/* Finds iterator for PHI. */
gphi_iterator
Except for the entry block. */
src = e->src;
if ((e->flags & EDGE_ABNORMAL) == 0
- && single_succ_p (src)
+ && (single_succ_p (src)
+ /* Do not count a fake edge as successor as added to infinite
+ loops by connect_infinite_loops_to_exit. */
+ || (EDGE_COUNT (src->succs) == 2
+ && (EDGE_SUCC (src, 0)->flags & EDGE_FAKE
+ || EDGE_SUCC (src, 1)->flags & EDGE_FAKE)))
&& src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
{
*gsi = gsi_last_bb (src);
return true;
tmp = gsi_stmt (*gsi);
- if (!stmt_ends_bb_p (tmp))
+ if (is_gimple_debug (tmp))
+ {
+ gimple_stmt_iterator si = *gsi;
+ gsi_prev_nondebug (&si);
+ if (!gsi_end_p (si))
+ tmp = gsi_stmt (si);
+ /* If we don't have a BB-ending nondebug stmt, we want to
+ insert after the trailing debug stmts. Otherwise, we may
+ insert before the BB-ending nondebug stmt, or split the
+ edge. */
+ if (!stmt_ends_bb_p (tmp))
+ return true;
+ *gsi = si;
+ }
+ else if (!stmt_ends_bb_p (tmp))
return true;
switch (gimple_code (tmp))