- /* process uses. (Phi inputs are no real uses) */
- if (!is_Phi(node)) {
- arity = get_irn_arity(node);
- for (i2 = 0; i2 < arity; ++i2) {
- ir_node *use = get_irn_n(node, i2);
- value_used(block, use);
- }
+ /* set must be empty now */
+ for (i = 0; i < n_regs; ++i) {
+ if (registers[i] == NULL)
+ continue;
+
+ ir_fprintf(stderr, "Verify warning: Node %+F not live-in and no def found in block %+F(%s)\n",
+ registers[i], block, get_irg_name(irg));
+ problem_found = true;
+ }
+}
+
+bool be_verify_register_allocation(ir_graph *new_irg)
+{
+ irg = new_irg;
+ arch_env = be_get_irg_arch_env(irg);
+ lv = be_liveness_new(irg);
+ problem_found = false;
+
+ be_liveness_compute_sets(lv);
+ irg_block_walk_graph(irg, verify_block_register_allocation, NULL, NULL);
+ be_liveness_free(lv);
+
+ return !problem_found;
+}
+
+/*--------------------------------------------------------------------------- */
+
+/**
+ * Walker: checks that every predecessors of a node dominates the node.
+ */
+static void dom_check(ir_node *irn, void *data)
+{
+ bool *problem_found = (bool*)data;
+
+ if (!is_Block(irn) && irn != get_irg_end(get_irn_irg(irn))) {
+ int i, n;
+ ir_node *bl = get_nodes_block(irn);
+
+ for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
+ ir_node *op = get_irn_n(irn, i);
+ ir_node *def_bl = get_nodes_block(op);
+ ir_node *use_bl = bl;
+
+ if (is_Phi(irn))
+ use_bl = get_Block_cfgpred_block(bl, i);
+
+ if (get_irn_opcode(use_bl) != iro_Bad
+ && get_irn_opcode(def_bl) != iro_Bad
+ && !block_dominates(def_bl, use_bl)) {
+ ir_fprintf(stderr, "Verify warning: %+F in %+F must dominate %+F for user %+F (%s)\n", op, def_bl, use_bl, irn, get_irg_name(get_irn_irg(op)));
+ *problem_found = true;