re PR debug/44205 (Wrong .debug_line for -O0 -g)
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 May 2010 09:26:31 +0000 (11:26 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 21 May 2010 09:26:31 +0000 (11:26 +0200)
PR debug/44205
* tree-cfgcleanup.c (tree_forwarder_block_p): Return false if
at -O0 goto_locus of any of the incoming edges differs from
goto_locus of outgoing edge, or gimple_location of any of the
labels differs.

From-SVN: r159652

gcc/ChangeLog
gcc/tree-cfgcleanup.c

index 2c7fcc0c58da3afe9dcd92468f7ae9d19e365fe6..f666191353a9c873d888811e1469be66ee2bd6ca 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/44205
+       * tree-cfgcleanup.c (tree_forwarder_block_p): Return false if
+       at -O0 goto_locus of any of the incoming edges differs from
+       goto_locus of outgoing edge, or gimple_location of any of the
+       labels differs.
+
 2009-09-14  Vladimir Makarov <vmakarov@redhat.com>
 
        * ira.c (ira_non_ordered_class_hard_regs): Define.
index 723bfc1be0fced90db2116508b79a80c20eb5aff..db7fb000af8d6d56aad257db7961c9c7a67cfba6 100644 (file)
@@ -267,6 +267,7 @@ static bool
 tree_forwarder_block_p (basic_block bb, bool phi_wanted)
 {
   gimple_stmt_iterator gsi;
+  location_t locus;
 
   /* BB must have a single outgoing edge.  */
   if (single_succ_p (bb) != 1
@@ -285,6 +286,8 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
   gcc_assert (bb != ENTRY_BLOCK_PTR);
 #endif
 
+  locus = single_succ_edge (bb)->goto_locus;
+
   /* There should not be an edge coming from entry, or an EH edge.  */
   {
     edge_iterator ei;
@@ -293,6 +296,10 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
     FOR_EACH_EDGE (e, ei, bb->preds)
       if (e->src == ENTRY_BLOCK_PTR || (e->flags & EDGE_EH))
        return false;
+      /* If goto_locus of any of the edges differs, prevent removing
+        the forwarder block for -O0.  */
+      else if (optimize == 0 && e->goto_locus != locus)
+       return false;
   }
 
   /* Now walk through the statements backward.  We can ignore labels,
@@ -306,6 +313,8 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
        case GIMPLE_LABEL:
          if (DECL_NONLOCAL (gimple_label_label (stmt)))
            return false;
+         if (optimize == 0 && gimple_location (stmt) != locus)
+           return false;
          break;
 
          /* ??? For now, hope there's a corresponding debug
@@ -608,11 +617,7 @@ cleanup_tree_cfg_bb (basic_block bb)
 
   retval = cleanup_control_flow_bb (bb);
 
-  /* Forwarder blocks can carry line number information which is
-     useful when debugging, so we only clean them up when
-     optimizing.  */
-  if (optimize > 0
-      && tree_forwarder_block_p (bb, false)
+  if (tree_forwarder_block_p (bb, false)
       && remove_forwarder_block (bb))
     return true;