Fix random scheduler.
authorManuel Mohr <manuel.mohr@kit.edu>
Mon, 23 Jul 2012 12:15:28 +0000 (14:15 +0200)
committerManuel Mohr <manuel.mohr@kit.edu>
Mon, 23 Jul 2012 12:33:32 +0000 (14:33 +0200)
After the switch to C99, the foreach_ir_nodeset macro introduced a separate
loop variable, which shadowed the local variable "irn".  Thus, an uninitialized
pointer was passed to is_cfop.

ir/be/beschedrand.c

index da3e2f2..394b771 100644 (file)
@@ -48,25 +48,26 @@ static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
                }
        }
 
-       ir_node *irn;
+       ir_node *rand_node = NULL;
        if (only_branches_left) {
                /* at last: schedule branches */
-               irn = ir_nodeset_first(ready_set);
+               rand_node = ir_nodeset_first(ready_set);
        } else {
                do {
                        /* take 1 random node */
                        int n = rand() % ir_nodeset_size(ready_set);
                        int i = 0;
                        foreach_ir_nodeset(ready_set, irn, iter) {
+                               rand_node = irn;
                                if (i == n) {
                                        break;
                                }
                                ++i;
                        }
-               } while (is_cfop(irn));
+               } while (is_cfop(rand_node));
        }
 
-       return irn;
+       return rand_node;
 }
 
 static void *random_init_graph(ir_graph *irg)