- ir_node *alloc, *next, *mem, *sel, *size, *blk;
- ir_type *ftp, *atp, *tp;
- ir_entity *ent;
- char name[128];
- unsigned nr = 0;
- dbg_info *dbg;
-
- /* kill all dead allocs */
- for (alloc = env->dead_allocs; alloc; alloc = next) {
- next = (ir_node*)get_irn_link(alloc);
-
- DBG((dbgHandle, LEVEL_1, "%+F allocation of %+F unused, deleted.\n", irg, alloc));
-
- mem = get_Alloc_mem(alloc);
- blk = get_nodes_block(alloc);
- turn_into_tuple(alloc, pn_Alloc_max);
- set_Tuple_pred(alloc, pn_Alloc_M, mem);
- set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
- set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
-
- ++env->nr_deads;
- }
-
- /* convert all non-escaped heap allocs into frame variables */
- ftp = get_irg_frame_type(irg);
- for (alloc = env->found_allocs; alloc; alloc = next) {
- next = (ir_node*)get_irn_link(alloc);
- size = get_Alloc_count(alloc);
- atp = get_Alloc_type(alloc);
-
- tp = NULL;
- if (is_SymConst(size) && get_SymConst_kind(size) == symconst_type_size) {
- /* if the size is a type size and the types matched */
- assert(atp == get_SymConst_type(size));
- tp = atp;
- } else if (is_Const(size)) {
- ir_tarval *tv = get_Const_tarval(size);
-
- if (tv != tarval_bad && tarval_is_long(tv) &&
- get_type_state(atp) == layout_fixed &&
- (unsigned)get_tarval_long(tv) == get_type_size_bytes(atp)) {
- /* a already lowered type size */
- tp = atp;
- }
- }
-
- if (tp && tp != firm_unknown_type) {
- /* we could determine the type, so we could place it on the frame */
- dbg = get_irn_dbg_info(alloc);
- blk = get_nodes_block(alloc);
-
- DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on frame\n", irg, alloc, tp));
-
- snprintf(name, sizeof(name), "%s_NE_%u", get_entity_name(get_irg_entity(irg)), nr++);
- name[sizeof(name) - 1] = '\0';
- ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg);
-
- sel = new_rd_simpleSel(dbg, get_nodes_block(alloc), get_irg_no_mem(irg), get_irg_frame(irg), ent);
- mem = get_Alloc_mem(alloc);
-
- turn_into_tuple(alloc, pn_Alloc_max);
- set_Tuple_pred(alloc, pn_Alloc_M, mem);
- set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
- set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
- set_Tuple_pred(alloc, pn_Alloc_res, sel);
-
- ++env->nr_removed;
- }
- else {
- /*
- * We could not determine the type or it is variable size.
- * At least, we could place it on the stack
- */
- DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on stack\n", irg, alloc));
- set_Alloc_where(alloc, stack_alloc);
-
- ++env->nr_changed;
- }
- }
-
- /* if allocs were removed somehow */
- if (env->nr_removed && env->nr_deads) {
- /* exception control flow might have been changed */
- set_irg_doms_inconsistent(irg);
- }
+ ir_node *alloc, *next, *mem, *sel, *size, *blk;
+ ir_type *ftp, *atp, *tp;
+ ir_entity *ent;
+ char name[128];
+ unsigned nr = 0;
+ dbg_info *dbg;
+
+ /* kill all dead allocs */
+ for (alloc = env->dead_allocs; alloc; alloc = next) {
+ next = (ir_node*)get_irn_link(alloc);
+
+ DBG((dbgHandle, LEVEL_1, "%+F allocation of %+F unused, deleted.\n", irg, alloc));
+
+ mem = get_Alloc_mem(alloc);
+ blk = get_nodes_block(alloc);
+ turn_into_tuple(alloc, pn_Alloc_max+1);
+ set_Tuple_pred(alloc, pn_Alloc_M, mem);
+ set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
+ set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
+
+ ++env->nr_deads;
+ }
+
+ /* convert all non-escaped heap allocs into frame variables */
+ ftp = get_irg_frame_type(irg);
+ for (alloc = env->found_allocs; alloc; alloc = next) {
+ next = (ir_node*)get_irn_link(alloc);
+ size = get_Alloc_count(alloc);
+ atp = get_Alloc_type(alloc);
+
+ tp = NULL;
+ if (is_SymConst(size) && get_SymConst_kind(size) == symconst_type_size) {
+ /* if the size is a type size and the types matched */
+ assert(atp == get_SymConst_type(size));
+ tp = atp;
+ } else if (is_Const(size)) {
+ ir_tarval *tv = get_Const_tarval(size);
+
+ if (tv != tarval_bad && tarval_is_long(tv) &&
+ get_type_state(atp) == layout_fixed &&
+ (unsigned)get_tarval_long(tv) == get_type_size_bytes(atp)) {
+ /* a already lowered type size */
+ tp = atp;
+ }
+ }
+
+ if (tp && !is_unknown_type(tp)) {
+ /* we could determine the type, so we could place it on the frame */
+ dbg = get_irn_dbg_info(alloc);
+ blk = get_nodes_block(alloc);
+
+ DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on frame\n", irg, alloc, tp));
+
+ snprintf(name, sizeof(name), "%s_NE_%u", get_entity_name(get_irg_entity(irg)), nr++);
+ name[sizeof(name) - 1] = '\0';
+ ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg);
+
+ sel = new_rd_simpleSel(dbg, get_nodes_block(alloc), get_irg_no_mem(irg), get_irg_frame(irg), ent);
+ mem = get_Alloc_mem(alloc);
+
+ turn_into_tuple(alloc, pn_Alloc_max+1);
+ set_Tuple_pred(alloc, pn_Alloc_M, mem);
+ set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk));
+ set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg, mode_X));
+ set_Tuple_pred(alloc, pn_Alloc_res, sel);
+
+ ++env->nr_removed;
+ }
+ else {
+ /*
+ * We could not determine the type or it is variable size.
+ * At least, we could place it on the stack
+ */
+ DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on stack\n", irg, alloc));
+ set_Alloc_where(alloc, stack_alloc);
+
+ ++env->nr_changed;
+ }
+ }
+
+ /* if allocs were removed somehow */
+ if (env->nr_removed && env->nr_deads) {
+ /* exception control flow might have been changed */
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
+ }