X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fldstopt.c;h=d5358791797c6785cb8362fee62dfff30fb89c6c;hb=5992483ac7f47c78e5315897faf715fc840f32ce;hp=e1ec07ad34a7c1a5d9a430a1202371aeb751e7c0;hpb=bc2fb78aa23428b803837576d87bb7615c070ddd;p=libfirm diff --git a/ir/opt/ldstopt.c b/ir/opt/ldstopt.c index e1ec07ad3..d53587917 100644 --- a/ir/opt/ldstopt.c +++ b/ir/opt/ldstopt.c @@ -315,7 +315,7 @@ static compound_graph_path *rec_get_accessed_path(ir_node *ptr, int depth) { if (get_irn_op(ptr) == op_SymConst) { assert(get_SymConst_kind(ptr) == symconst_addr_ent); root = get_SymConst_entity(ptr); - res = depth == 0 ? NULL : new_compound_graph_path(get_entity_type(root), depth); + res = (depth == 0) ? NULL : new_compound_graph_path(get_entity_type(root), depth); } else { assert(get_irn_op(ptr) == op_Sel); @@ -339,7 +339,6 @@ static compound_graph_path *get_accessed_path(ir_node *ptr) { return rec_get_accessed_path(ptr, 0); } - /** * optimize a Load */ @@ -366,7 +365,7 @@ static int optimize_load(ir_node *load) if (get_irn_op(ptr) == op_Sel) { ir_node *mem = get_Sel_mem(ptr); - if (get_irn_op(mem) == op_Alloc) { + if (get_irn_op(skip_Proj(mem)) == op_Alloc) { /* ok, check the types */ entity *ent = get_Sel_entity(ptr); type *s_type = get_entity_type(ent); @@ -381,7 +380,8 @@ static int optimize_load(ir_node *load) } } } - else if (get_irn_op(ptr) == op_Alloc) { + else if ((get_irn_op(skip_Proj(ptr)) == op_Alloc) || + ((get_irn_op(ptr) == op_Cast) && (get_irn_op(skip_Proj(get_Cast_op(ptr))) == op_Alloc))) { /* simple case: a direct load after an Alloc. Firm Alloc throw * an exception in case of out-of-memory. So, there is no way for an * exception in this load. @@ -466,12 +466,12 @@ static int optimize_load(ir_node *load) } else if (variability_constant == get_entity_variability(ent)) { compound_graph_path *path; - + /* printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent), get_entity_name(get_irg_entity(current_ir_graph))); printf(" load: "); DDMN(load); printf(" ptr: "); DDMN(ptr); - + */ path = get_accessed_path(ptr); if (path) { ir_node *c; @@ -479,13 +479,13 @@ static int optimize_load(ir_node *load) assert(is_proper_compound_graph_path(path, get_compound_graph_path_length(path)-1)); c = get_compound_ent_value_by_path(ent, path); - printf(" cons: "); DDMN(c); + /* printf(" cons: "); DDMN(c); */ if (info->projs[pn_Load_M]) exchange(info->projs[pn_Load_M], mem); if (info->projs[pn_Load_res]) exchange(info->projs[pn_Load_res], copy_const_value(c)); - + /* { int j; for (j = 0; j < get_compound_graph_path_length(path); ++j) { @@ -496,8 +496,20 @@ static int optimize_load(ir_node *load) } printf("\n"); } - } else + */ + } else { + /* We can not determine a correct access path. E.g., in jack, we load + a byte from an object to generate an exception. Happens in test program + Reflectiontest. + printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent), + get_entity_name(get_irg_entity(current_ir_graph))); + printf(" load: "); DDMN(load); + printf(" ptr: "); DDMN(ptr); + if (get_irn_op(ptr) == op_SymConst && + get_SymConst_kind(ptr) == symconst_addr_ent) { printf(" "); DDMEO(get_SymConst_entity(ptr)); } printf("cannot optimize.\n"); + */ + } } /* we changed the irg, but try further */ @@ -537,8 +549,10 @@ static int optimize_load(ir_node *load) */ if ((!pred_info->projs[pn_Store_X_except] && !info->projs[pn_Load_X_except]) || get_nodes_block(load) == get_nodes_block(pred)) { - DBG_OPT_RAW(load, pred); - exchange( info->projs[pn_Load_res], get_Store_value(pred) ); + ir_node *value = get_Store_value(pred); + + DBG_OPT_RAW(load, value); + exchange(info->projs[pn_Load_res], value); if (info->projs[pn_Load_M]) exchange(info->projs[pn_Load_M], mem);