Commit bb62c5ab authored by Matthias Braun's avatar Matthias Braun
Browse files

add a bitset_copy_into function and use it in belive.c to avoid assertion failures

[r27348]
parent 8b7e7d88
......@@ -184,6 +184,12 @@ static inline void bitset_copy(bitset_t *tgt, const bitset_t *src)
rbitset_copy(tgt->data, src->data, src->size);
}
static inline void bitset_copy_into(bitset_t *tgt, const bitset_t *src)
{
assert(tgt->size >= src->size);
rbitset_copy_into(tgt->data, src->data, src->size);
}
/**
* Find the next unset bit from a given bit.
* @note Note that if pos is unset, pos is returned.
......
......@@ -587,4 +587,14 @@ static inline void rbitset_copy(unsigned *dst, const unsigned *src,
memcpy(dst, src, BITSET_SIZE_BYTES(size));
}
static inline void rbitset_copy_into(unsigned *dst, const unsigned *src,
unsigned size)
{
unsigned n = BITSET_SIZE_ELEMS(size);
unsigned last_mask = rbitset_last_mask_(size);
memcpy(dst, src, (n-1) * (BITS_PER_ELEM/8));
dst[n-1] = (src[n-1] & last_mask) | (dst[n-1] & ~last_mask);
}
#endif
......@@ -284,7 +284,7 @@ static void register_node(be_lv_t *lv, const ir_node *irn)
unsigned idx = get_irn_idx(irn);
if (idx >= bitset_size(lv->nodes)) {
bitset_t *nw = bitset_malloc(2 * idx);
bitset_copy(nw, lv->nodes);
bitset_copy_into(nw, lv->nodes);
bitset_free(lv->nodes);
lv->nodes = nw;
}
......
Supports Markdown
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