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);
return rec_get_accessed_path(ptr, 0);
}
-
/**
* optimize a 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);
}
}
}
- 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.
}
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;
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) {
}
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 */