do not cache types in global variables
authorMatthias Braun <matze@braunis.de>
Tue, 10 Jan 2012 12:10:22 +0000 (13:10 +0100)
committerMatthias Braun <matze@braunis.de>
Tue, 10 Jan 2012 12:11:17 +0000 (13:11 +0100)
(or multiple ir_init/ir_finishs will fail)

ir/ir/irtypes.h
ir/tr/type.c

index d7eecb7..f73b99c 100644 (file)
@@ -629,6 +629,7 @@ struct ir_prog {
        ir_type   *none_type;           /**< unique 'none'-type */
        ir_type   *code_type;           /**< unique 'code'-type */
        ir_type   *unknown_type;        /**< unique 'unknown'-type */
+       ir_type   *byte_type;           /**< type for a 'byte' */
        ident    **global_asms;         /**< An array of global ASM insertions. */
 
        /* -- states of and access to generated information -- */
index 4e08126..abf559f 100644 (file)
@@ -2026,20 +2026,19 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
        char buf[32];
        int offset, frame_size;
        static unsigned area_cnt = 0;
-       static ir_type *a_byte = NULL;
 
        assert(is_frame_type(frame_type));
        assert(get_type_state(frame_type) == layout_fixed);
        assert(get_type_alignment_bytes(frame_type) > 0);
        set_type_state(frame_type, layout_undefined);
 
-       if (! a_byte)
-               a_byte = new_type_primitive(mode_Bu);
+       if (irp->byte_type == NULL)
+               irp->byte_type = new_type_primitive(mode_Bu);
 
        snprintf(buf, sizeof(buf), "area%u", area_cnt++);
        name = new_id_from_str(buf);
 
-       tp = new_type_array(1, a_byte);
+       tp = new_type_array(1, irp->byte_type);
        set_array_bounds_int(tp, 0, 0, size);
        set_type_alignment_bytes(tp, alignment);
        set_type_size_bytes(tp, size);