Index: gcc/lra-constraints.c
===================================================================
--- gcc/lra-constraints.c	2012-10-17 16:36:34.000000000 +0100
+++ gcc/lra-constraints.c	2012-10-18 09:49:57.331283959 +0100
@@ -4199,7 +4199,7 @@ split_reg (bool before_p, int original_r
 			  -1, 0);
 	}
     }
-  lra_assert (NONDEBUG_INSN_P (usage_insn));
+  lra_assert (NOTE_P (usage_insn) || NONDEBUG_INSN_P (usage_insn));
   lra_assert (usage_insn != insn || (after_p && before_p));
   lra_process_new_insns (usage_insn, after_p ? NULL_RTX : restore,
 			 after_p ? restore : NULL_RTX,
@@ -4380,30 +4380,17 @@ add_to_inherit (int regno, rtx insns)
   to_inherit[to_inherit_num++].insns = insns;
 }
 
-/* Return first non-debug insn in basic block BB.  Return null if
-   there are no non-debug insns in the block.  */
+/* Return the last non-debug insn in basic block BB, or the block begin
+   note if none.  */
 static rtx
-get_first_non_debug_insn (basic_block bb)
-{
-  rtx insn;
-
-  FOR_BB_INSNS (bb, insn)
-    if (NONDEBUG_INSN_P (insn))
-      return insn;
-  return NULL_RTX;
-}
-
-/* Return last non-debug insn in basic block BB.  Return null if there
-   are no non-debug insns in the block.  */
-static rtx
-get_last_non_debug_insn (basic_block bb)
+get_last_insertion_point (basic_block bb)
 {
   rtx insn;
 
   FOR_BB_INSNS_REVERSE (bb, insn)
-    if (NONDEBUG_INSN_P (insn))
+    if (NONDEBUG_INSN_P (insn) || NOTE_INSN_BASIC_BLOCK_P (insn))
       return insn;
-  return NULL_RTX;
+  gcc_unreachable ();
 }
 
 /* Set up RES by registers living on edges FROM except the edge (FROM,
@@ -4421,7 +4408,8 @@ get_live_on_other_edges (basic_block fro
   FOR_EACH_EDGE (e, ei, from->succs)
     if (e->dest != to)
       bitmap_ior_into (res, DF_LR_IN (e->dest));
-  if ((last = get_last_non_debug_insn (from)) == NULL_RTX || ! JUMP_P (last))
+  last = get_last_insertion_point (from);
+  if (! JUMP_P (last))
     return;
   curr_id = lra_get_insn_recog_data (last);
   for (reg = curr_id->regs; reg != NULL; reg = reg->next)
@@ -4450,7 +4438,7 @@ inherit_in_ebb (rtx head, rtx tail)
 {
   int i, src_regno, dst_regno;
   bool change_p, succ_p;
-  rtx prev_insn, next_usage_insns, set, first_insn, last_insn;
+  rtx prev_insn, next_usage_insns, set, last_insn;
   enum reg_class cl;
   struct lra_insn_reg *reg;
   basic_block last_processed_bb, curr_bb = NULL;
@@ -4486,8 +4474,8 @@ inherit_in_ebb (rtx head, rtx tail)
 	      to_process = &temp_bitmap;
 	    }
 	  last_processed_bb = curr_bb;
-	  last_insn = get_last_non_debug_insn (curr_bb);
-	  after_p = (last_insn != NULL_RTX && ! JUMP_P (last_insn)
+	  last_insn = get_last_insertion_point (curr_bb);
+	  after_p = (! JUMP_P (last_insn)
 		     && (! CALL_P (last_insn)
 			 || find_reg_note (last_insn,
 					   REG_NORETURN, NULL) == NULL_RTX));
@@ -4730,7 +4718,6 @@ inherit_in_ebb (rtx head, rtx tail)
 	{
 	  /* We reached the beginning of the current block -- do
 	     rest of spliting in the current BB.  */
-	  first_insn = get_first_non_debug_insn (curr_bb);
 	  to_process = DF_LR_IN (curr_bb);
 	  if (BLOCK_FOR_INSN (head) != curr_bb)
 	    {	
@@ -4748,8 +4735,7 @@ inherit_in_ebb (rtx head, rtx tail)
 		  && usage_insns[j].check == curr_usage_insns_check
 		  && (next_usage_insns = usage_insns[j].insns) != NULL_RTX)
 		{
-		  if (first_insn != NULL_RTX
-		      && need_for_split_p (potential_reload_hard_regs, j))
+		  if (need_for_split_p (potential_reload_hard_regs, j))
 		    {
 		      if (lra_dump_file != NULL && head_p)
 			{
@@ -4757,7 +4743,8 @@ inherit_in_ebb (rtx head, rtx tail)
 				   "  ----------------------------------\n");
 			  head_p = false;
 			}
-		      if (split_reg (true, j, first_insn, next_usage_insns))
+		      if (split_reg (false, j, bb_note (curr_bb),
+				     next_usage_insns))
 			change_p = true;
 		    }
 		  usage_insns[j].check = 0;
