diff mbox series

retain debug stmt order when moving to successors

Message ID orsfzy52b6.fsf@lxoliva.fsfla.org
State New
Headers show
Series retain debug stmt order when moving to successors | expand

Commit Message

Alexandre Oliva July 28, 2021, 7:23 a.m. UTC
We iterate over debug stmts from the last one in new_bb, and we insert
them before the first post-label stmt in each dest block, without
moving the insertion iterator, so they end up reversed.  Moving the
insertion iterator fixes this.

Regstrapped on x86_64-linux-gnu.  Ok to install?

for  gcc/ChangeLog

	* tree-inline.c (maybe_move_debug_stmts_to_successors): Don't
	reverse debug stmts.
---
 gcc/tree-inline.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Biener July 28, 2021, 12:34 p.m. UTC | #1
On Wed, Jul 28, 2021 at 10:12 AM Alexandre Oliva <oliva@adacore.com> wrote:
>
>
> We iterate over debug stmts from the last one in new_bb, and we insert
> them before the first post-label stmt in each dest block, without
> moving the insertion iterator, so they end up reversed.  Moving the
> insertion iterator fixes this.
>
> Regstrapped on x86_64-linux-gnu.  Ok to install?

OK.

Richard.

> for  gcc/ChangeLog
>
>         * tree-inline.c (maybe_move_debug_stmts_to_successors): Don't
>         reverse debug stmts.
> ---
>  gcc/tree-inline.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
> index 4a07d88f10bc5..b188a21df0e07 100644
> --- a/gcc/tree-inline.c
> +++ b/gcc/tree-inline.c
> @@ -2868,7 +2868,7 @@ maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
>                   gimple_set_location (stmt, UNKNOWN_LOCATION);
>                 }
>               gsi_remove (&si, false);
> -             gsi_insert_before (&dsi, stmt, GSI_SAME_STMT);
> +             gsi_insert_before (&dsi, stmt, GSI_NEW_STMT);
>               continue;
>             }
>
> @@ -2894,7 +2894,7 @@ maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
>             new_stmt = as_a <gdebug *> (gimple_copy (stmt));
>           else
>             gcc_unreachable ();
> -         gsi_insert_before (&dsi, new_stmt, GSI_SAME_STMT);
> +         gsi_insert_before (&dsi, new_stmt, GSI_NEW_STMT);
>           id->debug_stmts.safe_push (new_stmt);
>           gsi_prev (&ssi);
>         }
>
>
> --
> Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
>    Free Software Activist                       GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about <https://stallmansupport.org>
Alexandre Oliva Aug. 17, 2021, 11:04 a.m. UTC | #2
On Jul 28, 2021, Richard Biener <richard.guenther@gmail.com> wrote:

> OK.

Thanks, I've finally put this in.  Sorry about the delay.

> On Wed, Jul 28, 2021 at 10:12 AM Alexandre Oliva <oliva@adacore.com> wrote:
>> * tree-inline.c (maybe_move_debug_stmts_to_successors): Don't
>> reverse debug stmts.
diff mbox series

Patch

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 4a07d88f10bc5..b188a21df0e07 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2868,7 +2868,7 @@  maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
 		  gimple_set_location (stmt, UNKNOWN_LOCATION);
 		}
 	      gsi_remove (&si, false);
-	      gsi_insert_before (&dsi, stmt, GSI_SAME_STMT);
+	      gsi_insert_before (&dsi, stmt, GSI_NEW_STMT);
 	      continue;
 	    }
 
@@ -2894,7 +2894,7 @@  maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
 	    new_stmt = as_a <gdebug *> (gimple_copy (stmt));
 	  else
 	    gcc_unreachable ();
-	  gsi_insert_before (&dsi, new_stmt, GSI_SAME_STMT);
+	  gsi_insert_before (&dsi, new_stmt, GSI_NEW_STMT);
 	  id->debug_stmts.safe_push (new_stmt);
 	  gsi_prev (&ssi);
 	}