fixed CopyB emitter
[libfirm] / ir / be / bespill.c
index 29d2a7d..94c22c9 100644 (file)
@@ -799,6 +799,7 @@ static ir_type *get_spill_type(pmap *types, spill_slot_t *ss) {
        if (! e) {
                char buf[64];
                snprintf(buf, sizeof(buf), "spill_slot_type_%s", get_mode_name(ss->largest_mode));
+               buf[sizeof(buf) - 1] = '\0';
                res = new_type_primitive(new_id_from_str(buf), ss->largest_mode);
                set_type_alignment_bytes(res, ss->align);
                pmap_insert(types, ss->largest_mode, res);
@@ -819,12 +820,17 @@ static ir_type *get_spill_type(pmap *types, spill_slot_t *ss) {
  */
 static void assign_entities(ss_env_t *ssenv, int n_slots, spill_slot_t *ss[]) {
        int i, offset, frame_align;
-       ir_type *frame = get_irg_frame_type(ssenv->cenv->irg);
+       ir_type *frame;
+
+       /* do not align the frame if no spill slots are needed */
+       if (n_slots <= 0)
+               return;
+
+       frame = get_irg_frame_type(ssenv->cenv->irg);
 
        /* aligning by increasing frame size */
-       offset = get_type_size_bits(frame) / 8;
+       offset = get_type_size_bytes(frame);
        offset = round_up2(offset, ALIGN_SPILL_AREA);
-       set_type_size_bytes(frame, -1);
 
        /* create entities and assign offsets according to size and alignment*/
        for (i = 0; i < n_slots; ++i) {
@@ -835,6 +841,7 @@ static void assign_entities(ss_env_t *ssenv, int n_slots, spill_slot_t *ss[]) {
 
                /* build entity */
                snprintf(buf, sizeof(buf), "spill_slot_%d", i);
+               buf[sizeof(buf) - 1] = '\0';
                name = new_id_from_str(buf);
 
                spill_ent = new_entity(frame, name, get_spill_type(ssenv->types, ss[i]));