add some is_*() functions
[libfirm] / ir / ir / irvrfy.c
index 1b392e0..2cf817d 100644 (file)
@@ -1427,6 +1427,31 @@ static int verify_node_Phi(ir_node *n, ir_graph *irg) {
       );
   }
   ASSERT_AND_RET( mode_is_dataM(mymode), "Phi node", 0 );
+
+  if (mymode == mode_M) {
+    for (i = get_Phi_n_preds(n) - 1; i >= 0; --i) {
+      int j;
+      ir_node *pred_i = get_Phi_pred(n, i);
+
+      if (is_Bad(pred_i))
+        continue;
+      for (j = i - 1; j >= 0; --j) {
+        ir_node *pred_j = get_Phi_pred(n, j);
+
+        if (is_Bad(pred_j))
+          continue;
+#if 0
+        /* did NOT work with the current exception model where blocks a NOT basic blocks */
+        ASSERT_AND_RET_DBG(
+          (pred_i == pred_j) || (get_irn_n(pred_i, -1) != get_irn_n(pred_j, -1)),
+          "At least two different PhiM predecessors are in the same block",
+          0,
+          ir_printf("%+F and %+F of %+F are in %+F\n", pred_i, pred_j, n, get_irn_n(pred_i, -1))
+        );
+#endif
+      }
+    }
+  }
   return 1;
 }
 
@@ -1658,11 +1683,13 @@ static int verify_node_Bound(ir_node *n, ir_graph *irg) {
   return 1;
 }
 
-/*
+/**
  * Check dominance.
  * For each usage of a node, it is checked, if the block of the
  * node dominates the block of the usage (for phis: the predecessor
  * block of the phi for the corresponding edge).
+ *
+ * @return non-zero on success, 0 on dominance error
  */
 static int check_dominance_for_node(ir_node *use)
 {
@@ -1832,7 +1859,7 @@ int irn_vrfy_irg_dump(ir_node *n, ir_graph *irg, const char **bad_string)
   firm_vrfy_failure_msg = NULL;
   do_node_verification(FIRM_VERIFICATION_ERROR_ONLY);
   res = irn_vrfy_irg(n, irg);
-  if (res && get_irg_dom_state(irg) == dom_consistent &&
+  if (res && get_irg_dom_state(irg) == dom_consistent &&
       get_irg_pinned(irg) == op_pin_state_pinned)
     res = check_dominance_for_node(n);
   do_node_verification(old);