This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't merge blocks in gimple at -O0 if that would lose goto_locus (PR debug/44375)


Hi!

At -O0 -g we don't often emit any instructions with location
of return stmt, either for return; stmts or when NRV happens.

The problem is that the return is turned into a goto and merge_blocks
then removes it, as the goto is to immediately following stmt.

The following patch fixes it by avoiding the merge at -O0 in
such cases.  The RTL cfg cleanups know how to handle this
and insert a nop insn with the right locus afterwards.
Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?

Alternative patch is in the PR - emitting GIMPLE_NOP in between the stmts
and for -O0 expand GIMPLE_NOPs with location as nop insns with that
location.

2010-06-02  Jakub Jelinek  <jakub@redhat.com>

	PR debug/44375
	* tree-cfg.c (gimple_can_merge_blocks_p): For -O0
	return false if merging the bbs would lead to goto_locus
	location being lost from the IL.

--- gcc/tree-cfg.c.jj	2010-06-01 12:27:48.000000000 +0200
+++ gcc/tree-cfg.c	2010-06-02 10:47:41.000000000 +0200
@@ -1477,6 +1477,23 @@ gimple_can_merge_blocks_p (basic_block a
       && name_mappings_registered_p ())
     return false;
 
+  /* When not optimizing, don't merge if we'd lose goto_locus.  */
+  if (!optimize
+      && single_succ_edge (a)->goto_locus != UNKNOWN_LOCATION)
+    {
+      location_t goto_locus = single_succ_edge (a)->goto_locus;
+      gimple_stmt_iterator prev, next;
+      prev = gsi_last_nondebug_bb (a);
+      next = gsi_after_labels (b);
+      if (!gsi_end_p (next) && is_gimple_debug (gsi_stmt (next)))
+	gsi_next_nondebug (&next);
+      if ((gsi_end_p (prev)
+	   || gimple_location (gsi_stmt (prev)) != goto_locus)
+	  && (gsi_end_p (next)
+	      || gimple_location (gsi_stmt (next)) != goto_locus))
+	return false;
+    }
+
   return true;
 }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]