Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 191819)
+++ cfgrtl.c	(working copy)
@@ -2033,6 +2033,7 @@ rtl_verify_flow_info_1 (void)
   rtx x;
   int err = 0;
   basic_block bb;
+  bool have_partitions = false;

   /* Check the general integrity of the basic blocks.  */
   FOR_EACH_BB_REVERSE (bb)
@@ -2145,6 +2146,8 @@ rtl_verify_flow_info_1 (void)
 	    n_eh++;
 	  else if (e->flags & EDGE_ABNORMAL)
 	    n_abnormal++;
+
+	  have_partitions |= is_crossing;
 	}

       if (n_eh && !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX))
@@ -2263,6 +2268,40 @@ rtl_verify_flow_info_1 (void)
 	  }
     }

+  /* If there are partitions, do a sanity check on them: A basic block in
+     a cold partition cannot dominate a basic block in a hot partition.  */
+  VEC (basic_block, heap) *bbs_in_cold_partition = NULL;
+  if (have_partitions && !err)
+    FOR_EACH_BB (bb)
+      if ((BB_PARTITION (bb) == BB_COLD_PARTITION))
+	VEC_safe_push (basic_block, heap, bbs_in_cold_partition, bb);
+  if (! VEC_empty (basic_block, bbs_in_cold_partition))
+    {
+      bool dom_calculated_here = !dom_info_available_p (CDI_DOMINATORS);
+      basic_block son;
+
+      if (dom_calculated_here)
+	calculate_dominance_info (CDI_DOMINATORS);
+
+      while (! VEC_empty (basic_block, bbs_in_cold_partition))
+	{
+	  bb = VEC_pop (basic_block, bbs_in_cold_partition);
+	  if ((BB_PARTITION (bb) != BB_COLD_PARTITION))
+	    {
+	      error ("non-cold basic block %d dominated "
+		     "by a block in the cold partition", bb->index);
+	      err = 1;
+	    }
+	  for (son = first_dom_son (CDI_DOMINATORS, bb);
+	       son;
+	       son = next_dom_son (CDI_DOMINATORS, son))
+	    VEC_safe_push (basic_block, heap, bbs_in_cold_partition, son);
+	}
+
+      if (dom_calculated_here)
+	free_dominance_info (CDI_DOMINATORS);
+    }
+
   /* Clean up.  */
   return err;
 }
