OSDN Git Service

* config/darwin.h (LINK_COMMAND_SPEC): Add .cxx/.cp for dsymutil
[pf3gnuchains/gcc-fork.git] / gcc / lower-subreg.c
index 908b10e..ac29272 100644 (file)
@@ -35,6 +35,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "recog.h"
 #include "bitmap.h"
 #include "expr.h"
+#include "except.h"
 #include "regs.h"
 #include "tree-pass.h"
 
@@ -521,6 +522,31 @@ resolve_subreg_use (rtx *px, void *data)
   return 0;
 }
 
+/* We are deleting INSN.  Move any EH_REGION notes to INSNS.  */
+
+static void
+move_eh_region_note (rtx insn, rtx insns)
+{
+  rtx note, p;
+
+  note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
+  if (note == NULL_RTX)
+    return;
+
+  gcc_assert (CALL_P (insn)
+             || (flag_non_call_exceptions && may_trap_p (PATTERN (insn))));
+
+  for (p = insns; p != NULL_RTX; p = NEXT_INSN (p))
+    {
+      if (CALL_P (p)
+         || (flag_non_call_exceptions
+             && INSN_P (p)
+             && may_trap_p (PATTERN (p))))
+       REG_NOTES (p) = gen_rtx_EXPR_LIST (REG_EH_REGION, XEXP (note, 0),
+                                          REG_NOTES (p));
+    }
+}
+
 /* If there is a REG_LIBCALL note on OLD_START, move it to NEW_START,
    and link the corresponding REG_RETVAL note to NEW_START.  */
 
@@ -837,6 +863,8 @@ resolve_simple_move (rtx set, rtx insn)
   insns = get_insns ();
   end_sequence ();
 
+  move_eh_region_note (insn, insns);
+
   emit_insn_before (insns, insn);
 
   move_libcall_note (insn, insns);
@@ -1022,15 +1050,20 @@ decompose_multiword_subregs (bool update_life)
     {
       int hold_no_new_pseudos = no_new_pseudos;
       int max_regno = max_reg_num ();
-      sbitmap blocks;
+      sbitmap life_blocks;
+      sbitmap sub_blocks;
+      unsigned int i;
+      sbitmap_iterator sbi;
       bitmap_iterator iter;
       unsigned int regno;
 
       propagate_pseudo_copies ();
 
       no_new_pseudos = 0;
-      blocks = sbitmap_alloc (last_basic_block);
-      sbitmap_zero (blocks);
+      life_blocks = sbitmap_alloc (last_basic_block);
+      sbitmap_zero (life_blocks);
+      sub_blocks = sbitmap_alloc (last_basic_block);
+      sbitmap_zero (sub_blocks);
 
       EXECUTE_IF_SET_IN_BITMAP (decomposable_context, 0, regno, iter)
        decompose_register (regno);
@@ -1073,14 +1106,35 @@ decompose_multiword_subregs (bool update_life)
                  if (set)
                    {
                      rtx orig_insn = insn;
+                     bool cfi = control_flow_insn_p (insn);
+
+                     /* We can end up splitting loads to multi-word pseudos
+                        into separate loads to machine word size pseudos.
+                        When this happens, we first had one load that can
+                        throw, and after resolve_simple_move we'll have a
+                        bunch of loads (at least two).  All those loads may
+                        trap if we can have non-call exceptions, so they
+                        all will end the current basic block.  We split the
+                        block after the outer loop over all insns, but we
+                        make sure here that we will be able to split the
+                        basic block and still produce the correct control
+                        flow graph for it.  */
+                     gcc_assert (!cfi
+                                 || (flag_non_call_exceptions
+                                     && can_throw_internal (insn)));
 
                      insn = resolve_simple_move (set, insn);
                      if (insn != orig_insn)
                        {
                          changed = true;
 
+                         remove_retval_note (insn);
+
                          recog_memoized (insn);
                          extract_insn (insn);
+
+                         if (cfi)
+                           SET_BIT (sub_blocks, bb->index);
                        }
                    }
 
@@ -1105,13 +1159,15 @@ decompose_multiword_subregs (bool update_life)
                      i = apply_change_group ();
                      gcc_assert (i);
 
+                     remove_retval_note (insn);
+
                      changed = true;
                    }
                }
 
              if (changed)
                {
-                 SET_BIT (blocks, bb->index);
+                 SET_BIT (life_blocks, bb->index);
                  reg_scan_update (insn, next, max_regno);
                }
            }
@@ -1120,10 +1176,41 @@ decompose_multiword_subregs (bool update_life)
       no_new_pseudos = hold_no_new_pseudos;
 
       if (update_life)
-       update_life_info (blocks, UPDATE_LIFE_GLOBAL_RM_NOTES,
+       update_life_info (life_blocks, UPDATE_LIFE_GLOBAL_RM_NOTES,
                          PROP_DEATH_NOTES);
 
-      sbitmap_free (blocks);
+      /* If we had insns to split that caused control flow insns in the middle
+        of a basic block, split those blocks now.  Note that we only handle
+        the case where splitting a load has caused multiple possibly trapping
+        loads to appear.  */
+      EXECUTE_IF_SET_IN_SBITMAP (sub_blocks, 0, i, sbi)
+       {
+         rtx insn, end;
+         edge fallthru;
+
+         bb = BASIC_BLOCK (i);
+         insn = BB_HEAD (bb);
+         end = BB_END (bb);
+
+         while (insn != end)
+           {
+             if (control_flow_insn_p (insn))
+               {
+                 /* Split the block after insn.  There will be a fallthru
+                    edge, which is OK so we keep it.  We have to create the
+                    exception edges ourselves.  */
+                 fallthru = split_block (bb, insn);
+                 rtl_make_eh_edge (NULL, bb, BB_END (bb));
+                 bb = fallthru->dest;
+                 insn = BB_HEAD (bb);
+               }
+             else
+               insn = NEXT_INSN (insn);
+           }
+       }
+
+      sbitmap_free (life_blocks);
+      sbitmap_free (sub_blocks);
     }
 
   {
@@ -1181,7 +1268,8 @@ struct tree_opt_pass pass_lower_subreg =
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
   TODO_dump_func |
-  TODO_ggc_collect,                     /* todo_flags_finish */
+  TODO_ggc_collect |
+  TODO_verify_flow,                     /* todo_flags_finish */
   'u'                                   /* letter */
 };
 
@@ -1199,6 +1287,7 @@ struct tree_opt_pass pass_lower_subreg2 =
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
   TODO_dump_func |
-  TODO_ggc_collect,                     /* todo_flags_finish */
+  TODO_ggc_collect |
+  TODO_verify_flow,                     /* todo_flags_finish */
   'U'                                   /* letter */
 };