- x = solve_lgs(matrix, rhs, size);
- if (x == NULL) {
- DEBUG_ONLY(ir_fprintf(stderr, "Debug Warning: Couldn't estimate execution frequencies for %+F\n", irg));
- ef->infeasible = 1;
- } else {
- ef->max = 0.0;
-
- set_foreach(freqs, freq) {
- const ir_node *bb = freq->irn;
- size_t idx = PTR_TO_INT(get_irn_link(bb));
-
-#ifdef USE_GSL
- freq->freq = UNDEF(gsl_vector_get(x, idx)) ? EPSILON : gsl_vector_get(x, idx);
-#else
- freq->freq = UNDEF(x[idx]) ? EPSILON : x[idx];
-#endif
-
- /* get the maximum exec freq */
- ef->max = MAX(ef->max, freq->freq);
-
- /* Get the minimum non-zero execution frequency. */
- if(freq->freq > 0.0)
- ef->min_non_zero = MIN(ef->min_non_zero, freq->freq);
- }
-
- /* compute m and b of the transformation used to convert the doubles into scaled ints */
- {
- double smallest_diff = 1.0;
-
- double l2 = ef->min_non_zero;
- double h2 = ef->max;
- double l1 = 1.0;
- double h1 = MAX_INT_FREQ;
-
- double *fs = malloc(set_count(freqs) * sizeof(fs[0]));
- int i, j, n = 0;
-
- set_foreach(freqs, freq)
- fs[n++] = freq->freq;
-
- /*
- * find the smallest difference of the execution frequencies
- * we try to ressolve it with 1 integer.
- */
- for(i = 0; i < n; ++i) {
- if(fs[i] <= 0.0)
- continue;
-
- for(j = i + 1; j < n; ++j) {
- double diff = fabs(fs[i] - fs[j]);
-
- if(!UNDEF(diff))
- smallest_diff = MIN(diff, smallest_diff);
- }
- }
-
- /* according to that the slope of the translation function is 1.0 / smallest diff */
- ef->m = 1.0 / smallest_diff;
-
- /* the abscissa is then given by */
- ef->b = l1 - ef->m * l2;
-
- /*
- * if the slope is so high that the largest integer would be larger than MAX_INT_FREQ
- * set the largest int freq to that upper limit and recompute the translation function
- */
- if(ef->m * h2 + ef->b > MAX_INT_FREQ) {
- ef->m = (h1 - l1) / (h2 - l2);
- ef->b = l1 - ef->m * l2;
- }
-
- // printf("smallest_diff: %g, l1: %f, h1: %f, l2: %f, h2: %f, m: %f, b: %f\n", smallest_diff, l1, h1, l2, h2, ef->m, ef->b);
- free(fs);
- }
+ /*
+ * Also add an edge for each kept block to start.
+ *
+ * This avoid strange results for e.g. an irg containing a exit()-call
+ * which block has no cfg successor.
+ */
+ ir_node *start_block = get_irg_start_block(irg);
+ int s_idx = size - dfs_get_post_num(dfs, start_block)-1;
+ const ir_node *end = get_irg_end(irg);
+ int n_keepalives = get_End_n_keepalives(end);
+ for (int idx = n_keepalives - 1; idx >= 0; --idx) {
+ ir_node *keep = get_End_keepalive(end, idx);
+ if (!is_Block(keep) || get_irn_n_edges_kind(keep, EDGE_KIND_BLOCK) > 0)
+ continue;