+
+/**
+ * check that all leader nodes in the partition have the same opcode.
+ */
+static void check_opcode(const partition_t *Z) {
+ node_t *node;
+ opcode_key_t key;
+ int first = 1;
+
+ list_for_each_entry(node_t, node, &Z->Leader, node_list) {
+ ir_node *irn = node->node;
+
+ if (first) {
+ key.code = get_irn_opcode(irn);
+ key.mode = get_irn_mode(irn);
+ key.arity = get_irn_arity(irn);
+ key.u.proj = 0;
+ key.u.ent = NULL;
+
+ switch (get_irn_opcode(irn)) {
+ case iro_Proj:
+ key.u.proj = get_Proj_proj(irn);
+ break;
+ case iro_Sel:
+ key.u.ent = get_Sel_entity(irn);
+ break;
+ default:
+ break;
+ }
+ first = 0;
+ } else {
+ assert(key.code == get_irn_opcode(irn));
+ assert(key.mode == get_irn_mode(irn));
+ assert(key.arity == get_irn_arity(irn));
+
+ switch (get_irn_opcode(irn)) {
+ case iro_Proj:
+ assert(key.u.proj == get_Proj_proj(irn));
+ break;
+ case iro_Sel:
+ assert(key.u.ent == get_Sel_entity(irn));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+} /* check_opcode */
+
+static void check_all_partitions(environment_t *env) {
+ partition_t *P;
+ node_t *node;
+
+#ifdef DEBUG_libfirm
+ for (P = env->dbg_list; P != NULL; P = P->dbg_next) {
+ check_partition(P);
+ if (! P->type_is_T_or_C)
+ check_opcode(P);
+ list_for_each_entry(node_t, node, &P->Follower, node_list) {
+ node_t *leader = identity(node);
+
+ assert(leader != node && leader->part == node->part);
+ }
+ }
+#endif
+}
+
+/**
+ * Check list.
+ */
+static void do_check_list(const node_t *list, int ofs, const partition_t *Z) {
+ const node_t *e;
+
+#define NEXT(e) *((const node_t **)((char *)(e) + (ofs)))
+ for (e = list; e != NULL; e = NEXT(e)) {
+ assert(e->part == Z);
+ }
+#undef NEXT
+} /* ido_check_list */
+
+/**
+ * Check a local list.
+ */
+static void check_list(const node_t *list, const partition_t *Z) {
+ do_check_list(list, offsetof(node_t, next), Z);
+} /* check_list */
+