Commit fe8a1fa4 authored by Moritz Hanke's avatar Moritz Hanke

Adds workaround for CCE compiler bug

parent 97de86aa
......@@ -1219,9 +1219,13 @@ idxsection_get_positions_of_indices_v3(Xt_idxlist body_idxlist,
unsorted_selection:
temp_selection_idx
= xmalloc((size_t)num_selection * sizeof(*temp_selection_idx));
// sorted_positions
// = xmalloc((size_t)num_selection * sizeof(*sorted_positions) * 2);
// selection_pos = sorted_positions + num_selection;
sorted_positions
= xmalloc((size_t)num_selection * sizeof(*sorted_positions) * 2);
selection_pos = sorted_positions + num_selection;
= xmalloc((size_t)num_selection * sizeof(*sorted_positions));
selection_pos
= xmalloc((size_t)num_selection * sizeof(*selection_pos));
memcpy(temp_selection_idx, selection_idx,
(size_t)num_selection * sizeof(*temp_selection_idx));
......@@ -1257,6 +1261,7 @@ sorted_selection:
positions[i] = sorted_positions[selection_pos[i]];
free(sorted_positions);
free(selection_pos);
free(temp_selection_idx);
}
......
......@@ -704,21 +704,27 @@ idxvec_get_positions_of_indices(Xt_idxlist body_idxlist,
if (selection_is_ordered) {
sorted_selection = selection_idx;
} else {
size_t idx_memsize = (size_t)num_selection * sizeof(*sorted_selection),
pos_memsize = (size_t)num_selection * sizeof(*sorted_selection_pos),
/* round pos_memsize up to next multiple of sizeof (int) */
pos_ofs = ((idx_memsize + sizeof (int) - 1)
& ((size_t)-(ssize_t)(sizeof(int)))),
/* compute size of merged allocation */
alloc_size = pos_ofs + pos_memsize;
tmp_idx = xmalloc(alloc_size);
memcpy(tmp_idx, selection_idx, idx_memsize);
sorted_selection_pos
= (void *)((unsigned char *)tmp_idx + pos_ofs);
xt_quicksort_index(tmp_idx, num_selection, sorted_selection_pos, 1);
// size_t idx_memsize = (size_t)num_selection * sizeof(*sorted_selection),
// pos_memsize = (size_t)num_selection * sizeof(*sorted_selection_pos),
// /* round pos_memsize up to next multiple of sizeof (int) */
// pos_ofs = ((idx_memsize + sizeof (int) - 1)
// & ((size_t)-(ssize_t)(sizeof(int)))),
// /* compute size of merged allocation */
// alloc_size = pos_ofs + pos_memsize;
// tmp_idx = xmalloc(alloc_size);
// memcpy(tmp_idx, selection_idx, idx_memsize);
// sorted_selection_pos
// = (void *)((unsigned char *)tmp_idx + pos_ofs);
// xt_quicksort_index(tmp_idx, num_selection, sorted_selection_pos, 1);
// sorted_selection = tmp_idx;
tmp_idx = xmalloc((size_t)num_selection * sizeof(*tmp_idx));
sorted_selection = tmp_idx;
memcpy(tmp_idx, selection_idx, (size_t)num_selection * sizeof(*tmp_idx));
sorted_selection_pos =
xmalloc((size_t)num_selection * sizeof(*sorted_selection_pos));
xt_quicksort_index(tmp_idx, num_selection, sorted_selection_pos, 1);
}
/* motivation for usage of single_match_only:
......@@ -792,7 +798,11 @@ idxvec_get_positions_of_indices(Xt_idxlist body_idxlist,
positions[sorted_selection_pos[i]] = -1;
} while (++i < (size_t)num_selection);
}
if (tmp_idx) free(tmp_idx);
// if (tmp_idx) free(tmp_idx);
if (sorted_selection_pos) {
free(tmp_idx);
free(sorted_selection_pos);
}
return num_unmatched;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment