summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-12-31 21:42:10 -0800
committerGary Oblock <gary@amperecomputing.com>2020-12-31 21:42:10 -0800
commit8cd7280db237ff06b45de75f6401ce6278c9da14 (patch)
tree246f13831a2591dfeff951c5de3f1ecbf604c522
parent4d3c3f539052c89a6b41b67f801417c2a8e0b522 (diff)
The unit tests except for mcf all pass and I'm getting
close on it.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c798
-rw-r--r--gcc/ipa-structure-reorg.c848
-rw-r--r--gcc/ipa-structure-reorg.h39
-rw-r--r--gcc/ipa-type-escape-analysis.c4
4 files changed, 1141 insertions, 548 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 60c8436c169..7f4c147c795 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -19,9 +19,6 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#define GATE1 0
-#define GATE2 0
-
#include <vector>
#include <map>
#include <set>
@@ -60,7 +57,6 @@ typedef struct acc_base_info acc_base_info_t;
typedef struct acc_info acc_info_t;
typedef struct varInfo varInfo_t;
-static void wrangle_ssa_type( tree, Info_t*);
//static bool print_internals (gimple *, void *);
static void str_reorg_instance_interleave_qual_part ( Info *);
static void str_reorg_instance_interleave_type_part ( Info *);
@@ -88,12 +84,19 @@ static void create_a_new_type ( Info_t *, tree);
static unsigned int reorg_perf_qual ( Info *);
static tree find_coresponding_field ( tree, tree);
static void remove_default_def ( tree, struct function *);
+#if 0
static void element_assign_transformation ( gimple *, ReorgType_t *, Info_t *);
+#endif
static void new_element_assign_transformation ( gimple *, ReorgType_t *, Info_t *);
static void element_assign_modif_trans ( gimple *, tree, Info_t *);
+#if 0
static void make_transformed_ref ( tree, ReorgType_t *, tree *, gimple_seq *, tree *, Info_t *);
+#endif
static void new_make_transformed_ref ( tree, ReorgType_t *, tree *, gimple_seq *, tree *, tree, Info_t *);
//static tree find_deepest_comp_ref ( tree);
+
+static tree new_create_deep_ref ( tree, tree, tree, Info_t *);
+static tree create_deep_ref_aux ( tree, tree, tree, tree *, tree *, Info_t *);
static tree create_deep_ref ( tree, tree, tree);
static void set_lhs_for ( gimple *, tree);
static basic_block make_bb ( char *, basic_block);
@@ -159,7 +162,7 @@ str_reorg_instance_interleave_trans ( Info *info)
if ( info->show_all_reorg_cands )
{
fprintf ( info->reorg_dump_file, "Start of str_reorg_instance_interleave_trans:\n");
- print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, false, 4, info);
}
//DEBUG ("INTERNALS PRINT\n");
@@ -207,7 +210,11 @@ str_reorg_instance_interleave_trans ( Info *info)
// If their type is modified then adjust the gimple.
#if 1
// Shouldn't this use new_contains_a_modified instead?
- tree modified = contains_a_modified ( stmt, info);
+ tree modified = contains_a_modified ( stmt,
+ #if ALLOW_REVERSE
+ true,
+ #endif
+ info);
if ( modified )
{
enum ReorgTransformation trans =
@@ -221,9 +228,17 @@ str_reorg_instance_interleave_trans ( Info *info)
fprintf ( stderr, "TBD at %s:%d\n", __FILE__, __LINE__);
break;
default:
+ DEBUG_LA ("No Transfrom on: ");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
+
;
}
}
+ else
+ {
+ DEBUG_LA ("Not modified or needing reorg: ");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
+ }
#endif
}
@@ -232,23 +247,22 @@ str_reorg_instance_interleave_trans ( Info *info)
#if USE_DO_INSTANCE_INTERLEAVE
if ( !ri->do_instance_interleave )
{
- //DEBUG_L("No Transfrom on: ");
- //DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
- DEBUG_L("SITUATION: ");
+ //DEBUG_LA ("No Transfrom on: ");
+ DEBUG_LA("SITUATION: ");
DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
continue;
}
#endif
- //DEBUG_F( print_reorg_with_msg, stderr, ri, 0,
- // "reorg from str_reorg_instance_interleave_trans");
+ DEBUG_F( print_reorg_with_msg, stderr, ri, 0,
+ "reorg from str_reorg_instance_interleave_trans");
enum ReorgTransformation trans =
reorg_recognize ( stmt, node, info);
// print out trans and stmt if dumping
if ( info->show_transforms )
{
- //DEBUG_L("Transform: ");
+ DEBUG_L("Transform: ");
print_gimple_stmt( info->reorg_dump_file, stmt, 0);
}
@@ -391,11 +405,11 @@ str_reorg_instance_interleave_trans ( Info *info)
gsi_insert_before( &gsi, do_rhs, GSI_SAME_STMT);
- element_assign_transformation ( do_rhs, ri, info);
+ new_element_assign_transformation ( do_rhs, ri, info);
gsi_insert_before( &gsi, do_lhs, GSI_SAME_STMT);
- element_assign_transformation ( do_lhs, ri, info);
+ new_element_assign_transformation ( do_lhs, ri, info);
}
gsi_remove ( &gsi, true);
}
@@ -406,11 +420,7 @@ str_reorg_instance_interleave_trans ( Info *info)
DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
INDENT(2);
- #if 1
new_element_assign_transformation (stmt, ri, info);
- #else
- element_assign_transformation (stmt, ri, info);
- #endif
INDENT(-2);
} // end ReorgT_ElemAssign case
@@ -1338,15 +1348,9 @@ str_reorg_instance_interleave_trans ( Info *info)
//DEBUG_F(print_generic_expr, stderr, res_type, (dump_flags_t)0);
//DEBUG("\n");
- #if 1
gcall *calloc_call = gimple_build_call( fndecl_calloc, 2, field_size, num_arg);
gimple_call_set_lhs( calloc_call, res);
SSA_NAME_DEF_STMT ( res) = calloc_call;
- #else
- gcall *malloc_call = gimple_build_call( fndecl_malloc, 1, mem_size);
- gimple_call_set_lhs( malloc_call, res);
- SSA_NAME_DEF_STMT ( res) = malloc_call;
- #endif
cgraph_node::get ( cfun->decl)->
create_edge ( cgraph_node::get_create ( fndecl_calloc),
@@ -2079,10 +2083,17 @@ str_reorg_instance_interleave_trans ( Info *info)
DEBUG_L("After bulk of transformations\n");
- DEBUG_F( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info);
-
+ DEBUG_F( print_program, info->reorg_dump_file, PRINT_FORMAT, false, 4, info);
+
DEBUG ("INTERNALS PRINT\n");
+ #if 0
DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);
+ #else
+ print_program ( stderr, true, true, 0, info);
+ #endif
+
+ // Experiment... Seems OK
+ modify_global_declarations ( info);
// A mini-pass to fixup dangling SSA temps.
@@ -2448,11 +2459,15 @@ str_reorg_instance_interleave_trans ( Info *info)
// I'm leaning towards deleting this as redundnt.
//DEBUG ( info->reorg_dump_file,
// "\nEnd of str_reorg_instance_interleave_trans (after mini-psasses):\n\n");
- //DEBUG_F ( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info);
+ //DEBUG_F ( print_program, info->reorg_dump_file, PRINT_FORMAT, false, 4, info);
// TBD Should this be a diagnostic or not?
DEBUG ("INTERNALS PRINT\n");
+ #if 0
DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);
+ #else
+ print_program ( stderr, true, true, 0, info);
+ #endif
// NOTE, spinning through all the functions and recomputing all the
// dominace info here is a really bad idea.
@@ -2460,14 +2475,19 @@ str_reorg_instance_interleave_trans ( Info *info)
return 0;
}
+#if 0
static void
element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
{
gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
- DEBUG_L("element_assign_transformation: ");
+ DEBUG_L("element_assign_transformation:> ");
DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
- tree modif_type = contains_a_modified ( stmt, info);
+ tree modif_type = contains_a_modified ( stmt,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
DEBUG_A("Modification for = ");
DEBUG_F(flexible_print, stderr, modif_type, 1, (dump_flags_t)0);
@@ -2495,7 +2515,7 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
tree ref_expr;
tree field_val_temp;
gimple_seq ref_seq = NULL;
-
+
make_transformed_ref ( ro_side, ri, &ref_expr, &ref_seq, &field_val_temp, info);
gimple *temp_set;
@@ -2604,19 +2624,20 @@ element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
INDENT(-2);
}
+#endif
static void
new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
{
gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
- DEBUG_A("new_element_assign_transformation: ");
- DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+ DEBUG_LA("new_element_assign_transformation:>\n");
INDENT(2);
+ DEBUG_A("stmt = ");
+ DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
+ DEBUG_A("ri = ");
+ DEBUG_F( print_reorg, stderr, 0, ri);
- #if GATE1
- tree modif_type = contains_a_modified ( stmt, info);
- #else
tree lhs_mod;
tree rhs_mod;
bool has_modification =
@@ -2626,7 +2647,6 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
DEBUG_F(flexible_print, stderr, lhs_mod, 1, (dump_flags_t)0);
DEBUG_A("rhs_mod = ");
DEBUG_F(flexible_print, stderr, rhs_mod, 1, (dump_flags_t)0);
- #endif
// Needed for helloworld
tree lhs = gimple_assign_lhs( stmt);
@@ -2644,6 +2664,8 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
DEBUG_A("ro_side = ");
DEBUG_F(flexible_print, stderr, ro_side, 1, (dump_flags_t)0);
enum ReorgOpTrans optype = recognize_op ( ro_side, true, info);
+ DEBUG_A("optype = %s\n", optrans_to_str ( optype));
+
switch ( optype ) // "a->f"
{
case ReorgOpT_Indirect:
@@ -2652,13 +2674,9 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
tree field_val_temp;
gimple_seq ref_seq = NULL;
- #if GATE1
- new_make_transformed_ref ( ro_side, ri, &ref_expr, &ref_seq, &field_val_temp, modif_type, info);
- #else
new_make_transformed_ref ( ro_side, ri, &ref_expr, &ref_seq, &field_val_temp,
ro_on_left ? lhs_mod : rhs_mod,
info);
- #endif
gimple *temp_set;
gimple *middle_set;
@@ -2718,7 +2736,7 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info)
tree rhs_ref = ref_expr;
// If these will actually print then things are likely sane
- DEBUG_L("rhs_ref: ");
+ DEBUG_LA("rhs_ref: ");
DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0);
DEBUG("\n");
@@ -2775,6 +2793,7 @@ element_assign_modif_trans ( gimple *stmt, tree type, Info_t *info)
gcc_assert(0);
}
+#if 0
// For ref_in which is a ReorgOpT_Indirect, create gimple
// sequence to setup a transformed ref and the ref itself.
static void
@@ -2785,7 +2804,6 @@ make_transformed_ref ( tree ref_in,
tree *field_val_temp,
Info_t *info )
{
-
// For deeply nested case we need the lowest.
tree lowest_comp_ref = find_deepest_comp_ref ( ref_in);
gcc_assert ( lowest_comp_ref);
@@ -2876,6 +2894,7 @@ make_transformed_ref ( tree ref_in,
gimple_seq_add_stmt ( pre_ref_seq, get_offset);
gimple_seq_add_stmt ( pre_ref_seq, get_field_addr);
}
+#endif
// For ref_in which is a ReorgOpT_Indirect, create gimple
// sequence to setup a transformed ref and the ref itself.
@@ -2888,24 +2907,33 @@ new_make_transformed_ref ( tree ref_in,
tree modif_type,
Info_t *info )
{
- DEBUG_A("new_make_transformed_ref:\n");
+ DEBUG_LA("new_make_transformed_ref:> ");
+ DEBUG_F(flexible_print, stderr, ref_in, 1, (dump_flags_t)0);
INDENT(2);
tree gcc_type = ri->gcc_type;
+ tree mod_gcc_type = find_modified ( gcc_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+
+ tree reorg_ver_type = ri->reorg_ver_type;
+
+ tree mod_ver_type = find_modified ( reorg_ver_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
DEBUG_A("gcc_type = ");
DEBUG_F(flexible_print, stderr, gcc_type, 1, (dump_flags_t)0);
DEBUG_A("modif_type = ");
DEBUG_F(flexible_print, stderr, modif_type, 1, (dump_flags_t)0);
-
- tree mod_gcc_type = find_modified ( gcc_type, info);
-
DEBUG_A("mod_gcc_type = ");
DEBUG_F(flexible_print, stderr, mod_gcc_type, 1, (dump_flags_t)0);
- tree reorg_ver_type = ri->reorg_ver_type;
DEBUG_A("reorg_ver_type = ");
DEBUG_F(flexible_print, stderr, reorg_ver_type, 1, (dump_flags_t)0);
- tree mod_ver_type = find_modified ( reorg_ver_type, info);
DEBUG_A("mod_ver_type = ");
DEBUG_F(flexible_print, stderr, mod_ver_type, 1, (dump_flags_t)0);
@@ -2913,119 +2941,208 @@ new_make_transformed_ref ( tree ref_in,
// For deeply nested case we need the lowest.
tree lowest_comp_ref = find_deepest_comp_ref ( ref_in);
gcc_assert ( lowest_comp_ref);
- DEBUG_A("lowest_comp_ref = ");
- DEBUG_F(flexible_print, stderr, lowest_comp_ref, 1, (dump_flags_t)0);
tree orig_field = TREE_OPERAND ( lowest_comp_ref, 1);
tree field_type = TREE_TYPE ( orig_field);
tree base = ri->instance_interleave.base;
+ DEBUG_A("lowest_comp_ref = ");
+ DEBUG_F(flexible_print, stderr, lowest_comp_ref, 1, (dump_flags_t)0);
DEBUG_A("orig_field = ");
DEBUG_F(flexible_print, stderr, orig_field, 1, (dump_flags_t)0);
DEBUG_A("field_type = ");
DEBUG_F(flexible_print, stderr, field_type, 1, (dump_flags_t)0);
DEBUG_A("base = ");
DEBUG_F(flexible_print, stderr, base, 1, (dump_flags_t)0);
-
- tree base_field =
- find_coresponding_field ( base, orig_field);
+
+ tree look_in_struct_type = base;
+ DEBUG_A("look_in_struct_type (default) = ");
+ DEBUG_F(flexible_print, stderr, look_in_struct_type, 1, (dump_flags_t)0);
+
+ tree deep_type = find_deepest_comp_ref_type ( ref_in);
+ DEBUG_A("deep_type = ");
+ DEBUG_F(flexible_print, stderr, deep_type, 1, (dump_flags_t)0);
+ bool a_reorg = is_reorg_type ( deep_type, info);
+
+ bool use_modified = false;
+ // TBD The conditions on this is a bit sloppy...
+ //
+ if ( !a_reorg && modif_type != NULL )
+ {
+ tree mod_mod_ver_type = find_modified ( modif_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+ if ( mod_mod_ver_type != NULL )
+ {
+ look_in_struct_type = mod_mod_ver_type;
+ use_modified = true;
+ DEBUG_A("look_in_struct_type (mod_mod_ver_type) = ");
+ DEBUG_F(flexible_print, stderr, look_in_struct_type, 1, (dump_flags_t)0);
+ }
+ }
+ DEBUG_A("use_modified = %s\n", use_modified ? "true" : "false");
+
+
+ // TBD figure out when this is actually true!
+ bool create_addr_expr_stmts_for_reorg = false;
+
+ tree deepest = find_deepest_comp_ref (ref_in);
+ DEBUG_LA("deepest = ");
+ DEBUG_F(flexible_print, stderr, deepest, 1, (dump_flags_t)0);
+ tree inner_op0 = TREE_OPERAND( deepest, 0);
+ DEBUG_A("inner_op0 = ");
+ DEBUG_F(flexible_print, stderr, inner_op0, 1, (dump_flags_t)0);
+ enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
+ bool possible = inner_op0_code == MEM_REF;
+ if ( possible ) {
+ // TBD also add check if this is a reorg type
+ tree inner_op0_type = TREE_TYPE( inner_op0);
+ DEBUG_A("inner_op0_type = ");
+ DEBUG_F(flexible_print, stderr, inner_op0_type, 1, (dump_flags_t)0);
+ tree inner_op0_type_base = base_type_of ( inner_op0_type);
+ if ( is_reorg_type ( inner_op0_type_base, info) )
+ {
+ create_addr_expr_stmts_for_reorg = true;
+ }
+ }
+ tree field_addr = NULL;
+
+ tree base_field =
+ find_coresponding_field ( look_in_struct_type, orig_field);
+
tree base_field_type = TREE_TYPE( base_field);
-
+
DEBUG_A("base_field = ");
DEBUG_F(flexible_print, stderr, base_field, 1, (dump_flags_t)0);
DEBUG_A("base_field_type = ");
DEBUG_F(flexible_print, stderr, base_field_type, 1, (dump_flags_t)0);
-
+
// The this changes because it the lowest field now
tree top_field_type = TREE_TYPE ( ref_in);
*field_val_temp =
make_temp_ssa_name( top_field_type, NULL, "field_val_temp");
-
- // NOTE. Things get weird fast if inner_op is a decl.
- tree inner_op = TREE_OPERAND( lowest_comp_ref, 0);
- #if GATE2
- inner_op = TREE_OPERAND( inner_op, 0);
- #else
- // Note before I had the following here which fails wheter or
- // not inner_op is a decl.
- // inner_op = TREE_OPERAND( inner_op, 0);
- if ( TREE_CODE ( inner_op) == MEM_REF )
- {
- DEBUG_A("peeled MEM_REF off of inner_op\n");
- inner_op = TREE_OPERAND( inner_op, 0);
- }
- #endif
-
- DEBUG_A("inner_op = ");
- DEBUG_F(flexible_print, stderr, inner_op, 1, (dump_flags_t)0);
- DEBUG_A("TREE_CODE(inner_op) = %s\n", code_str( TREE_CODE(inner_op)));
-
- // For either case generate common code:
-
- // field_array = _base.f
- gcc_assert ( base_field_type);
- // Note, this looks like trouble because this is a structure
- // type for a deeply nested type. Maybe wrap it it in a
- // pointer if deeply nested???
- tree field_arry_addr =
- make_temp_ssa_name( base_field_type, NULL, "field_arry_addr");
-
- tree rhs_faa = build3 ( COMPONENT_REF,
- base_field_type,
- base,
- base_field,
- NULL_TREE);
-
- // Use this to access the array of element.
- gimple *get_field_arry_addr =
- gimple_build_assign( field_arry_addr, rhs_faa);
- SSA_NAME_DEF_STMT ( field_arry_addr) = get_field_arry_addr;
-
- // index = a
- gcc_assert ( sizetype);
- tree index =
- make_temp_ssa_name( sizetype, NULL, "index");
- gimple *get_index =
- gimple_build_assign( index, CONVERT_EXPR, inner_op);
- SSA_NAME_DEF_STMT ( index) = get_index;
- DEBUG_A("get_index stmt = ");
- DEBUG_F ( print_gimple_stmt, stderr, get_index, TDF_DETAILS);
+ DEBUG_A("create_addr_expr_stmts_for_reorg = %s\n",
+ create_addr_expr_stmts_for_reorg ? "true" : "false");
+
+ if ( create_addr_expr_stmts_for_reorg )
+ {
+ // NOTE, the sequence of the emitted code will be drastically
+ // different if a modification of a var decl is happening instead of
+ // mem ref.
+ // We are punting on this for thr grins of it for now.... I want to
+ // see what breaks.
- // offset = index * size_of_field
-
- // Note base_field_type is a pointer and we want the size of what's
- // pointed to.
- tree size_of_field = TYPE_SIZE_UNIT ( field_type);
+ #if 0
+ // The this changes because it the lowest field now
+ tree top_field_type = TREE_TYPE ( ref_in);
+
+ *field_val_temp =
+ make_temp_ssa_name( top_field_type, NULL, "field_val_temp");
+ #endif
+
+ // NOTE. Things get weird fast if inner_op is a decl.
+ tree inner_op = TREE_OPERAND( lowest_comp_ref, 0);
+
+ // Note before I had the following here which fails wheter or
+ // not inner_op is a decl.
+ // inner_op = TREE_OPERAND( inner_op, 0);
+ if ( TREE_CODE ( inner_op) == MEM_REF )
+ {
+ DEBUG_A("peeled MEM_REF off of inner_op\n");
+ inner_op = TREE_OPERAND( inner_op, 0);
+ }
+
+ DEBUG_A("inner_op = ");
+ DEBUG_F(flexible_print, stderr, inner_op, 1, (dump_flags_t)0);
+ DEBUG_A("TREE_CODE(inner_op) = %s\n", code_str( TREE_CODE(inner_op)));
+
+ // For either case generate common code:
+
+ // field_array = _base.f
+ gcc_assert ( base_field_type);
+ // Note, this looks like trouble because this is a structure
+ // type for a deeply nested type. Maybe wrap it it in a
+ // pointer if deeply nested???
+ tree field_arry_addr =
+ make_temp_ssa_name( base_field_type, NULL, "field_arry_addr");
+
+ tree rhs_faa = build3 ( COMPONENT_REF,
+ base_field_type,
+ base,
+ base_field,
+ NULL_TREE);
+
+ // Use this to access the array of element.
+ gimple *get_field_arry_addr =
+ gimple_build_assign( field_arry_addr, rhs_faa);
+ SSA_NAME_DEF_STMT ( field_arry_addr) = get_field_arry_addr;
+
+ // index = a
+ gcc_assert ( sizetype);
+ tree index =
+ make_temp_ssa_name( sizetype, NULL, "index");
+ gimple *get_index =
+ gimple_build_assign( index, CONVERT_EXPR, inner_op);
+ SSA_NAME_DEF_STMT ( index) = get_index;
+
+ DEBUG_A("get_index stmt = ");
+ DEBUG_F ( print_gimple_stmt, stderr, get_index, TDF_DETAILS);
+
+ // offset = index * size_of_field
+
+ // Note base_field_type is a pointer and we want the size of what's
+ // pointed to.
+ tree size_of_field = TYPE_SIZE_UNIT ( field_type);
+
+ gcc_assert ( sizetype);
+ tree offset = make_temp_ssa_name( sizetype, NULL, "offset");
+
+ gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
+ SSA_NAME_DEF_STMT ( offset) = get_offset;
+
+ DEBUG_LA("get_offset stmt = ");
+ DEBUG_F ( print_gimple_stmt, stderr, get_offset, TDF_DETAILS);
+
+ // field_addr = field_array + offset
+ gcc_assert ( base_field_type);
+ field_addr =
+ make_temp_ssa_name( base_field_type, NULL, "field_addr");
+ DEBUG_A("field_addr = ");
+ DEBUG_F(flexible_print, stderr, field_addr, 1, (dump_flags_t)0);
+ DEBUG_A(" its type = ");
+ DEBUG_F(flexible_print, stderr, base_field_type, 1, (dump_flags_t)0);
+
+ gimple *get_field_addr =
+ gimple_build_assign ( field_addr, POINTER_PLUS_EXPR, field_arry_addr, offset);
+ SSA_NAME_DEF_STMT ( field_addr) = get_field_addr;
+
+ DEBUG_A("get_field stmt = ");
+ DEBUG_F ( print_gimple_stmt, stderr, get_field_addr, TDF_DETAILS);
- gcc_assert ( sizetype);
- tree offset = make_temp_ssa_name( sizetype, NULL, "offset");
-
- gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
- SSA_NAME_DEF_STMT ( offset) = get_offset;
-
- // field_addr = field_array + offset
- gcc_assert ( base_field_type);
- tree field_addr =
- make_temp_ssa_name( base_field_type, NULL, "field_addr");
-
- gimple *get_field_addr =
- gimple_build_assign ( field_addr, POINTER_PLUS_EXPR, field_arry_addr, offset);
- SSA_NAME_DEF_STMT ( field_addr) = get_field_addr;
+ gimple_seq_add_stmt ( pre_ref_seq, get_field_arry_addr);
+ gimple_seq_add_stmt ( pre_ref_seq, get_index);
+ gimple_seq_add_stmt ( pre_ref_seq, get_offset);
+ gimple_seq_add_stmt ( pre_ref_seq, get_field_addr);
+ }
- // I'm thinking instead of field_type we need the corresponding field type
- // (base_field_type)
- //*ref_out = create_deep_ref ( ref_in, field_type, field_addr);
// Since this is a base field get rid of the extra pointer type
tree derefed_base_field_type = TREE_TYPE( base_field_type);
- *ref_out = create_deep_ref ( ref_in, derefed_base_field_type, field_addr);
+
+ DEBUG_A("derefed_base_field_type = ");
+ DEBUG_F(flexible_print, stderr, derefed_base_field_type, 1, (dump_flags_t)0);
- gimple_seq_add_stmt ( pre_ref_seq, get_field_arry_addr);
- gimple_seq_add_stmt ( pre_ref_seq, get_index);
- gimple_seq_add_stmt ( pre_ref_seq, get_offset);
- gimple_seq_add_stmt ( pre_ref_seq, get_field_addr);
+ // Of course if the field is a reorg pointer type then there is
+ // no extra pointer type level!
+ tree use_this_field_type =
+ derefed_base_field_type != NULL ? derefed_base_field_type : base_field_type;
+
+ *ref_out =
+ new_create_deep_ref ( ref_in, use_this_field_type, field_addr, info);
INDENT(-2);
}
@@ -3035,43 +3152,281 @@ new_make_transformed_ref ( tree ref_in,
tree
find_deepest_comp_ref ( tree comp_ref_expr )
{
- DEBUG_A("find_deepest_comp_ref of ");
- DEBUG_F(flexible_print, stderr, comp_ref_expr, 2, (dump_flags_t)0);
- DEBUG("tree code of %s\n", code_str( TREE_CODE(comp_ref_expr)));
- INDENT(2);
+ //DEBUG_A("find_deepest_comp_ref:> of ");
+ //DEBUG_F(flexible_print, stderr, comp_ref_expr, 2, (dump_flags_t)0);
+ //DEBUG("tree code of %s\n", code_str( TREE_CODE(comp_ref_expr)));
+ //INDENT(2);
enum tree_code code = TREE_CODE ( comp_ref_expr);
if ( code != COMPONENT_REF && code != ARRAY_REF && code != MEM_REF )
{
- DEBUG_A("disqualified returns NULL\n");
- INDENT(-2);
+ //DEBUG_A("disqualified returns NULL\n");
+ //INDENT(-2);
return NULL;
}
tree inner_op0 = TREE_OPERAND( comp_ref_expr, 0);
enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
- DEBUG_A("inner_op0_code = %s\n", code_str ( inner_op0_code) );
+ //DEBUG_A("inner_op0_code = %s\n", code_str ( inner_op0_code) );
if ( inner_op0_code == COMPONENT_REF )
{
tree ret = find_deepest_comp_ref ( inner_op0);
- INDENT(-2);
+ //INDENT(-2);
return ret;
}
else if ( inner_op0_code == MEM_REF || inner_op0_code == VAR_DECL )
{
- DEBUG_A("bottom\n");
- INDENT(-2);
+ //DEBUG_A("bottom\n");
+ //INDENT(-2);
return comp_ref_expr;
}
- DEBUG_A("fell through returns NULL\n");
- INDENT(-2);
+ //DEBUG_A("fell through returns NULL\n");
+ //INDENT(-2);
return NULL;
}
static tree
+new_create_deep_ref ( tree ref_in,
+ tree field_type,
+ tree field_addr, // not used ??? Wrong!
+ Info_t *info )
+{
+ tree dummy1;
+ tree dummy2;
+ DEBUG_LA("new_create_deep_ref:>\n");
+ INDENT(2);
+ DEBUG_A("ref_in = ");
+ DEBUG_F(flexible_print, stderr, ref_in, 1, (dump_flags_t)0);
+ DEBUG_A("field_type = ");
+ DEBUG_F(flexible_print, stderr, field_type, 1, (dump_flags_t)0);
+ tree created =
+ create_deep_ref_aux (ref_in, field_type, field_addr, &dummy1, &dummy2, info);
+ DEBUG_A("returns: ");
+ DEBUG_F(flexible_print, stderr, created, 1, (dump_flags_t)0);
+
+ INDENT(-2);
+ return created;
+}
+
+
+static tree
+create_deep_ref_aux ( tree ref_in,
+ tree field_type, // Compute this here instead?
+ tree field_addr,
+ tree *lower_type_to,
+ tree *lower_type_from,
+ Info_t *info )
+{
+ DEBUG_LA("create_deep_ref_aux:>\n");\
+ INDENT(2);
+ enum tree_code top_code = TREE_CODE ( ref_in);
+
+ tree inner_op0 = TREE_OPERAND( ref_in, 0);
+ enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
+
+ DEBUG_A("inner_op0_code = %s\n", code_str ( inner_op0_code) );
+
+ if ( inner_op0_code == MEM_REF )
+ {
+ // TBD print: inner_op0, inner_op1, inner_op0_op0, inner_op0_op1,
+ tree inner_op1 = TREE_OPERAND( ref_in, 1);;
+ tree inner_op0_op0 = TREE_OPERAND( inner_op0, 0);
+ tree inner_op0_op0_type = TREE_TYPE ( inner_op0_op0);
+ tree inner_op0_op1 = TREE_OPERAND( inner_op0, 1);
+ DEBUG_A("inner_op0 = ");
+ DEBUG_F(flexible_print, stderr, inner_op0, 1, (dump_flags_t)0);
+ DEBUG_A("inner_op1 = ");
+ DEBUG_F(flexible_print, stderr, inner_op1, 1, (dump_flags_t)0);
+ DEBUG_A("inner_op0_op0 = ");
+ DEBUG_F(flexible_print, stderr, inner_op0_op0, 1, (dump_flags_t)0);
+ DEBUG_A("inner_op0_op0_type = ");
+ DEBUG_F(flexible_print, stderr, inner_op0_op0_type, 1, (dump_flags_t)0);
+ DEBUG_A("inner_op0_op1 = ");
+ DEBUG_F(flexible_print, stderr, inner_op0_op1, 1, (dump_flags_t)0);
+ if ( field_addr == NULL )
+ {
+ // Note, this surprisingly seems to be the only case seen
+ // in mcf. ???
+ //
+ DEBUG_A("field_addr == NULL\n");
+ // TBD lower_type_to and from are certainly WRONG!
+ // Or they at least should be!
+ tree to = find_modified ( field_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+ *lower_type_to = to;
+ //*lower_type_from = to ? field_type : NULL;
+ *lower_type_from = field_type;
+ if ( to == NULL )
+ {
+ to = find_modified ( field_type,
+ #if ALLOW_REVERSE
+ true,
+ #endif
+ info);
+ *lower_type_to = field_type;
+ *lower_type_from = to;
+ }
+ INDENT(-2);
+ // TBD I'm sure ome of the stuff above here is crap!
+
+ tree base = base_type_of ( inner_op0_op0_type);
+ tree modified_struct_type =
+ find_modified ( base, false, info); // ??? inner_op1
+
+ // This is the in_ref with a new field and field type.
+ tree new_field =
+ find_coresponding_field ( modified_struct_type, inner_op1);
+
+ tree new_comp_ref =
+ build3 ( COMPONENT_REF,
+ field_type,
+ inner_op0,
+ new_field, // ??? corresponding field?
+ NULL_TREE);
+
+ DEBUG_A("WHAT WE JUST BUILT...\n");
+ tree new_op0 = TREE_OPERAND( new_comp_ref, 0);
+ tree new_op1 = TREE_OPERAND( new_comp_ref, 1);;
+ tree new_op0_op0 = TREE_OPERAND( new_op0, 0);
+ tree new_op0_op0_type = TREE_TYPE ( new_op0_op0);
+ tree new_op0_op1 = TREE_OPERAND( new_op0, 1);
+ DEBUG_A("new_op0 = ");
+ DEBUG_F(flexible_print, stderr, new_op0, 1, (dump_flags_t)0);
+ DEBUG_A("new_op1 = ");
+ DEBUG_F(flexible_print, stderr, new_op1, 1, (dump_flags_t)0);
+ DEBUG_A("new_op0_op0 = ");
+ DEBUG_F(flexible_print, stderr, new_op0_op0, 1, (dump_flags_t)0);
+ DEBUG_A("new_op0_op0_type = ");
+ DEBUG_F(flexible_print, stderr, new_op0_op0_type, 1, (dump_flags_t)0);
+ return new_comp_ref;
+ }
+ else
+ {
+ // This case doesn'ty seem to happen
+ DEBUG_A("field_addr != NULL\n");
+ tree deepest =
+ build2 ( MEM_REF, field_type, field_addr,
+ build_int_cst (ptr_type_node, 0));
+
+ tree to = find_modified ( field_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+ *lower_type_to = to;
+ *lower_type_from = to ? field_type : NULL;
+ INDENT(-2);
+ // TBD Wrap the above with a component ref (if it ever happens)
+ return deepest;
+ }
+ }
+ else if ( inner_op0_code == VAR_DECL )
+ {
+ // The var decl type should already be modified???
+ // But we still need to pass up so find_modified
+ // needs to find the from and not the to!
+ tree ref_type = TREE_TYPE ( ref_in);
+ tree to = find_modified ( ref_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+ *lower_type_to = to;
+ *lower_type_from = to ? ref_type : NULL;
+ INDENT(-2);
+ return ref_in;
+ }
+ else if ( top_code == COMPONENT_REF )
+ {
+ DEBUG_A("COMPONENT_REF...\n");
+ tree lower_to;
+ tree lower_from;
+ tree lower_comp_part =
+ create_deep_ref_aux ( inner_op0, field_type, field_addr,
+ &lower_to, &lower_from, info);
+ DEBUG_A("lower_to (%p) = ");
+ DEBUG_F(flexible_print, stderr, lower_to, 1, (dump_flags_t)0);
+
+ // If we get a type back form the call we need to modify the
+ // field.
+ tree level_field;
+ tree level_field_type;
+ tree this_field = TREE_OPERAND( ref_in, 1);;
+ //tree this_field_type = TREE_TYPE ( level_field);
+
+ if ( lower_to == NULL )
+ {
+ level_field = this_field;
+ tree this_field_type = TREE_TYPE ( level_field);
+ level_field_type = this_field_type;
+ }
+ else
+ {
+ tree mod_field =
+ find_coresponding_field ( lower_to, this_field);
+ level_field = mod_field;
+ level_field_type = TREE_TYPE ( level_field);
+ }
+
+ tree component_layer =
+ build3 ( COMPONENT_REF,
+ level_field_type,
+ lower_comp_part,
+ level_field,
+ NULL_TREE);
+
+ INDENT(-2);
+ // TBD Set lower_type_to & lower_type_from!
+ *lower_type_to = lower_to == NULL ? NULL : level_field;
+ *lower_type_from = *lower_type_to == NULL ? NULL : TREE_TYPE ( this_field);
+ return component_layer;
+ }
+ else if ( top_code == ARRAY_REF )
+ {
+ tree lower_to;
+ tree lower_from;
+ tree lower_array_part =
+ create_deep_ref_aux ( inner_op0, field_type, field_addr,
+ &lower_to, &lower_from, info);
+
+ tree array_index = TREE_OPERAND( ref_in, 1);
+ tree this_elem_type = TREE_TYPE ( ref_in);
+ tree elem_type;
+
+ // Transform elem_type
+ if ( lower_to == NULL )
+ {
+ elem_type = this_elem_type;
+ }
+ else
+ {
+ elem_type = lower_to;
+ }
+
+ tree array_layer =
+ build4 ( ARRAY_REF,
+ elem_type,
+ lower_array_part,
+ array_index, // This is a constant
+ NULL_TREE, NULL_TREE);
+
+ INDENT(-2);
+ // TBD Set lower_type_to & lower_type_from!
+ *lower_type_to = lower_to == NULL ? NULL : elem_type;
+ *lower_type_from = this_elem_type;
+ return array_layer;
+ }
+ gcc_assert (0);
+}
+
+
+static tree
create_deep_ref ( tree ref_in, tree field_type, tree field_addr )
{
- DEBUG_A("create_deep_ref: ");
+ DEBUG_LA("create_deep_ref:> ");
DEBUG_F(flexible_print, stderr, ref_in, 1, (dump_flags_t)0);
INDENT(4);
enum tree_code top_code = TREE_CODE ( ref_in);
@@ -3167,56 +3522,6 @@ set_lhs_for ( gimple *stmt, tree ssa_name)
}
}
-// TBD no longer used... preserve it for a bit, then remove it.
-static void
-wrangle_ssa_type( tree side, Info_t *info )
-{
- tree side_type = TREE_TYPE ( side);
- tree bottom_type = base_type_of ( side_type);
- //DEBUG_L("op: ");
- //DEBUG_F(print_generic_expr, stderr, side, (dump_flags_t)0);
- //DEBUG("\n");
- //DEBUG_L("bottom_type: ");
- //DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
- //DEBUG("\n");
-
- // Maybe we sould pass in ri as an argument???
- ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
- tree prev_type = side_type;
- tree type = TREE_TYPE ( prev_type);
- //DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
- int levels;
- for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ )
- {
- prev_type = type;
- type = TREE_TYPE ( prev_type);
- //DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
- }
-
- // I thought about doing this:
- // Modify type of ssa temp (dicey!)
- // This changes every instance of * reorg_type to the
- // new pointre rep in one fell swoop.
- // I sweat just thinking how crazy this is....
- //
- // TREE_TYPE ( prev_type) = ri->pointer_rep;
-
- // TBD might use build_pointer_type to build new type for *(N)reorg_type
- // to *(N-1)ri->pointer_rep
- // Fakes this for levels == 1
- if ( levels == 0)
- {
- //DEBUG_L( "LEVELS ZERO\n");
- modify_ssa_name_type ( side, ri->pointer_rep);
- //DEBUG_L("after modify_ssa_name_type\n");
- }
- else
- {
- //DEBUG_L( "LEVELS > ZERO\n");
- gcc_assert(0);
- }
-}
-
void
print_internal_op ( tree op)
{
@@ -3407,7 +3712,7 @@ reorg_perf_qual ( Info *info)
{
fprintf ( info->reorg_dump_file, "Doing Performance Qualification\n");
}
- DEBUG_L("reorg_perf_qual:\n");
+ DEBUG_L("reorg_perf_qual:>\n");
#if USE_DO_INSTANCE_INTERLEAVE
// TBD use design in doc but mark ReorgTypes
// (do_instance_interleave) that qualify instead of deleting them
@@ -3873,7 +4178,7 @@ reorg_perf_qual ( Info *info)
if( ri != NULL ) {
ri->instance_interleave.regular_perf += regular_nca;
cache_accesses_noreorg += regular_nca;
- DEBUG_L("\n");
+ DEBUG_LA("\n");
DEBUG_A("Add regular_nca (%f) to regular_perf (now %e)",
regular_nca, ri->instance_interleave.regular_perf);
DEBUG_A(" and to cache_accesses_noreorg (now %e)\n",
@@ -4079,8 +4384,8 @@ reorg_perf_qual ( Info *info)
}
- #if USE_DO_INSTANCE_INTERLEAVE
- remove_deleted_types ( info, reorg_perf_qual_debug);
+ #if !USE_DO_INSTANCE_INTERLEAVE
+ remove_deleted_types ( info, "performance qualification", reorg_perf_qual_debug);
#endif
#endif
@@ -4111,7 +4416,7 @@ print_var_info ( FILE *file, varInfo_t &vinfo)
static void
print_var_infos ( FILE *file, std::vector<varInfo_t> &vinfo)
{
- fprintf( stderr, "print_var_infos:\n");
+ fprintf( stderr, "print_var_infos:>\n");
for ( auto vi = vinfo.begin (); vi != vinfo.end (); vi++ )
{
print_var_info ( file, *vi);
@@ -4122,7 +4427,7 @@ static void
compress_acc_infos ( std::vector <acc_info_t> ainfo )
{
unsigned len = ainfo.size ();
- //DEBUG_L("compress_acc_infos: len in %d, ",len);
+ //DEBUG_LA("compress_acc_infos:> len in %d, ",len);
if ( len <= 1 ) return;
unsigned i, j;
for ( i = j = 1; j < len; j++ )
@@ -4132,13 +4437,13 @@ compress_acc_infos ( std::vector <acc_info_t> ainfo )
}
if ( i == j ) return;
ainfo.resize ( len - (j -i));
- //DEBUG_L("len out %d, ", ainfo.size ());
+ //DEBUG_A ("len out %d, ", ainfo.size ());
}
static void
print_acc_info ( FILE *file, acc_info_t *ainfo )
{
- //DEBUG_L("print_acc_info: ainfo %p\n", ainfo);
+ //DEBUG_LA ("print_acc_info:> ainfo %p\n", ainfo);
fprintf ( file, "%s%s%s%s%s%s\n",
ainfo->base_info.a_def_def ? ", deflt_def" : "",
ainfo->base_info.a_decl ? ", decl" : "",
@@ -4168,7 +4473,7 @@ print_acc_info ( FILE *file, acc_info_t *ainfo )
static void
print_acc_infos ( FILE *file, std::vector <acc_info_t> ainfo )
{
- fprintf ( file, "print_acc_infos:\n");
+ fprintf ( file, "print_acc_infos:>\n");
unsigned i;
unsigned len = ainfo.size ();
@@ -4387,7 +4692,7 @@ tmasn_helper ( tree t, int indent, std::set<tree> *already )
{
fprintf( stderr, "\n");
}
- //DEBUG_L("code: %s\n", code_str(TREE_CODE (t)));
+ //DEBUG_A("code: %s\n", code_str(TREE_CODE (t)));
if ( TREE_CODE (t) == SSA_NAME )
{
already->insert (t);
@@ -4457,7 +4762,7 @@ tmasn_helper ( tree t, int indent, std::set<tree> *already )
static void
tell_me_about_ssa_name ( tree ssa_name, int indent)
{
- fprintf(stderr,"about:\n");
+ fprintf(stderr,"tell_me_about_ssa_name:>\n");
std::set<tree> already;
tmasn_helper ( ssa_name, indent, &already);
}
@@ -4588,7 +4893,7 @@ analyze_access ( tree access, acc_info_t *acc_info)
{
insane_helper = 0;
acc_base_info_t *base_info = &acc_info->base_info;
- //DEBUG_A("analyze_access:\n");
+ //DEBUG_A("analyze_access:>\n");
base_info->a_def_def = false;
base_info->a_decl = false;
base_info->a_func = false;
@@ -4604,7 +4909,7 @@ analyze_access ( tree access, acc_info_t *acc_info)
static void
create_pointer_reps ( Info_t *info)
{
- DEBUG_L("create_pointer_reps:\n");
+ DEBUG_FLA("create_pointer_reps:>\n");
std::map < tree, BoolPair_t>::iterator tmi;
for( tmi = info->struct_types->begin ();
tmi != info->struct_types->end ();
@@ -4615,7 +4920,7 @@ create_pointer_reps ( Info_t *info)
}
else
{
- DEBUG_L("processed\n");
+ DEBUG_A("processed\n");
}
}
}
@@ -4623,7 +4928,7 @@ create_pointer_reps ( Info_t *info)
static void
create_base_vars ( Info_t *info)
{
- DEBUG_L("create_base_vars:\n");
+ DEBUG_LA("create_base_vars:>\n");
std::map < tree, BoolPair_t>::iterator tmi;
for( tmi = info->struct_types->begin ();
tmi != info->struct_types->end ();
@@ -4634,7 +4939,7 @@ create_base_vars ( Info_t *info)
}
else
{
- DEBUG_L("processed\n");
+ DEBUG_A("processed\n");
}
}
}
@@ -4649,7 +4954,7 @@ create_base_vars ( Info_t *info)
static void
create_new_types ( Info_t *info)
{
- DEBUG_L("create_new_types:\n");
+ DEBUG_LA ("create_new_types:>\n");
std::map < tree, BoolPair_t>::iterator tmi;
for( tmi = info->struct_types->begin ();
tmi != info->struct_types->end ();
@@ -4673,7 +4978,7 @@ create_a_pointer_rep ( Info_t *info, tree type)
// skip if already processed
if ( ( *( info->struct_types))[type].processed ) return;
- DEBUG_L("create_a_pointer_rep: ");
+ DEBUG_LA("create_a_pointer_rep:> ");
DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
ReorgType_t *ri = get_reorgtype_info ( type, info);
@@ -4682,7 +4987,7 @@ create_a_pointer_rep ( Info_t *info, tree type)
tree reorg_type_prime = lang_hooks.types.make_type (RECORD_TYPE);
ri->reorg_ver_type = reorg_type_prime;
- DEBUG_L("TYPE_SIZE(reorg_type_prime): %p, ", TYPE_SIZE(reorg_type_prime));
+ DEBUG_LA ("TYPE_SIZE(reorg_type_prime): %p, ", TYPE_SIZE(reorg_type_prime));
DEBUG_F( print_generic_expr, stderr, TYPE_SIZE(reorg_type_prime), (dump_flags_t)-1);
DEBUG("\n");
@@ -4738,12 +5043,16 @@ create_a_base_var ( Info_t *info, tree type_in)
// skip if already processed
if ( ( *( info->struct_types))[type_in].processed ) return;
- DEBUG_L("create_a_base_var: ");
+ DEBUG_LA ("create_a_base_var:> ");
DEBUG_F(flexible_print, stderr, type_in, 1, (dump_flags_t)0);
tree type;
// Change to type to use modified type if it exists
- tree modified = find_modified ( type_in, info);
+ tree modified = find_modified ( type_in,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
if ( modified != NULL )
{
DEBUG_A("Use modified\n");
@@ -4772,7 +5081,7 @@ create_a_base_var ( Info_t *info, tree type_in)
strcpy ( rec_name, REORG_SP_PREFIX);
strcat ( rec_name, base_type_name);
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_LA ("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// Build the new pointer type fields
TYPE_NAME ( reorg_type_prime) = get_identifier ( rec_name);
@@ -4799,7 +5108,7 @@ create_a_base_var ( Info_t *info, tree type_in)
//DEBUG( "\n");
}
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_A("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// store reversed fields into reorg_type_prime
TYPE_FIELDS ( reorg_type_prime) = NULL;
@@ -4812,7 +5121,7 @@ create_a_base_var ( Info_t *info, tree type_in)
DECL_CHAIN ( field) = TYPE_FIELDS ( reorg_type_prime);
TYPE_FIELDS ( reorg_type_prime) = field;
}
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_A("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// Fix-up the layout
layout_type ( reorg_type_prime);
@@ -4898,7 +5207,7 @@ create_a_new_type ( Info_t *info, tree type)
// skip if already processed
if ( ( *( info->struct_types))[type].processed ) return;
- DEBUG_L("create_a_new_type: ");
+ DEBUG_L ("create_a_new_type:> ");
DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
// Implementation note: Check this for infinite recursion.
@@ -4927,7 +5236,7 @@ create_a_new_type ( Info_t *info, tree type)
tree reorg_type_prime = lang_hooks.types.make_type (RECORD_TYPE);
ri->reorg_ver_type = reorg_type_prime;
- DEBUG_L("TYPE_SIZE(reorg_type_prime): %p, ", TYPE_SIZE(reorg_type_prime));
+ DEBUG_LA ("TYPE_SIZE(reorg_type_prime): %p, ", TYPE_SIZE(reorg_type_prime));
DEBUG_F( print_generic_expr, stderr, TYPE_SIZE(reorg_type_prime), (dump_flags_t)-1);
DEBUG("\n");
@@ -4967,7 +5276,7 @@ create_a_new_type ( Info_t *info, tree type)
strcat ( name, gcc_name);
TYPE_NAME ( pointer_rep) = get_identifier ( name);
ri->pointer_rep = pointer_rep;
- DEBUG_L("pointer_rep = ");
+ DEBUG_A("pointer_rep = ");
DEBUG_F(flexible_print, stderr, pointer_rep, 1, (dump_flags_t)-1);
DEBUG_A("TYPE_MAIN_VARIANT ( pointer_rep) = ");
DEBUG_F(flexible_print, stderr, TYPE_MAIN_VARIANT (pointer_rep), 1, (dump_flags_t)-1);
@@ -4983,7 +5292,7 @@ create_a_new_type ( Info_t *info, tree type)
strcpy ( rec_name, REORG_SP_PREFIX);
strcat ( rec_name, base_type_name);
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_A("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// Build the new pointer type fields
TYPE_NAME ( reorg_type_prime) = get_identifier ( rec_name);
@@ -5010,7 +5319,7 @@ create_a_new_type ( Info_t *info, tree type)
//DEBUG( "\n");
}
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_LA ("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// store reversed fields into reorg_type_prime
TYPE_FIELDS ( reorg_type_prime) = NULL;
@@ -5023,7 +5332,7 @@ create_a_new_type ( Info_t *info, tree type)
DECL_CHAIN ( field) = TYPE_FIELDS ( reorg_type_prime);
TYPE_FIELDS ( reorg_type_prime) = field;
}
- //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+ //DEBUG_LA ("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// Fix-up the layout
layout_type ( reorg_type_prime);
@@ -5104,20 +5413,34 @@ create_a_new_type ( Info_t *info, tree type)
static tree
find_coresponding_field ( tree base_decl, tree field)
{
+ const char *field_name =
+ lang_hooks.decl_printable_name ( field, 2);
+ DEBUG_A("find_coresponding_field:> field_name = %s\n", field_name);
+ INDENT(2);
+ tree struct_type;
+ tree type_of = TREE_TYPE ( base_decl);
+ if ( type_of == NULL )
+ {
+ struct_type = base_decl;
+ }
+ else
+ {
+ struct_type = type_of;
+ }
+
tree reorg_field;
- for ( reorg_field = TYPE_FIELDS ( TREE_TYPE ( base_decl));
+ for ( reorg_field = TYPE_FIELDS ( struct_type);
reorg_field;
reorg_field = DECL_CHAIN ( reorg_field))
{
const char *reorg_field_name =
lang_hooks.decl_printable_name ( reorg_field, 2);
- const char *field_name =
- lang_hooks.decl_printable_name ( field, 2);
- DEBUG_L("LOOK %s, %s\n", reorg_field_name, field_name);
+ //DEBUG_A ("LOOK %s, %s\n", reorg_field_name, field_name);
if ( strcmp ( reorg_field_name, field_name) == 0 )
{
//gcc_assert ( TREE_TYPE( field) == TREE_TYPE( TREE_TYPE(reorg_field)));
+ INDENT(-2);
return reorg_field;
}
}
@@ -5143,10 +5466,25 @@ static basic_block
make_bb ( char *msg, basic_block prev_bb )
{
basic_block ret = create_empty_bb ( prev_bb);
- //DEBUG_A( "make_bb ( %s, <bb %d>/%p ): <bb %d>/%p, prev: <bb %d>/%p, next: <bb %d>/%p\n",
+ //DEBUG_A( "make_bb:> ( %s, <bb %d>/%p ): <bb %d>/%p, prev: <bb %d>/%p, next: <bb %d>/%p\n",
// msg, prev_bb->index, prev_bb,
// ret->index, ret,
// ret->prev_bb->index, ret->prev_bb,
// ret->next_bb->index, ret->next_bb);
return ret;
}
+
+void
+sneak_tree ( tree x)
+{
+ fprintf( stderr, "SNEAK OUT TREE!\n");
+ flexible_print ( stderr, x, 1, (dump_flags_t)-1);
+ fprintf( stderr, "\n");
+}
+void
+sneak_gimp ( gimple *x)
+{
+ fprintf ( stderr, "SNEAK OUT GIMPLE!\n");
+ print_gimple_stmt ( stderr, x, TDF_DETAILS);
+ fprintf ( stderr, "\n");
+}
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index ba496ad6578..439145a75b0 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -69,18 +69,10 @@ static unsigned int reorg_analysis ( Info *);
static unsigned number_of_executions ( gimple *, struct cgraph_node *);
static void reorg_analysis_debug ( Info *, ReorgType *);
static bool find_decls_and_types ( Info *);
-#if 1
static void find_all_record_types ( tree type, Info_t *);
-#if 0
-static void find_all_record_types ( std::map <tree,TypeHolder> *, tree type, Info_t *);
-static void find_and_create_all_modified_types ( std::map <tree,TypeHolder> *, Info_t *);
-#endif
static std::vector<tree>::iterator find_in_type_vec ( std::vector<tree> *, tree);
-static void dump_modified_types ( FILE *, Info_t *);
-#else
-static bool possibly_modify_pointer_types ( tree, Info_t *);
-#endif
-static tree find_deepest_comp_ref_type ( tree);
+static void dump_modified_types ( FILE *, bool, Info_t *);
+//static tree find_deepest_comp_ref_type ( tree);
#if USE_REORG_TYPES
static void add_reorg_type( tree, bool, Info *);
#endif
@@ -97,6 +89,7 @@ static void transformation_legality_debug ( Info *, ReorgType *);
static bool reorg_legality ( Info *);
static void reorg_common_middle_code ( Info *);
static void modify_declarations ( Info *);
+//static void modify_global_declarations ( Info *);
static bool modify_func_decl_core ( struct function *, Info *);
static void disqualify_all_reorgtypes_of ( gimple *, int, Info *);
static void adjust_result_decl ( struct function *);
@@ -128,7 +121,7 @@ static void print_detailed_reorgs ( FILE *, int, Info *);
static void print_progdecls ( FILE *, int, Info *);
static void print_progdecl ( FILE *, int, ProgDecl_t *);
//static void print_program ( FILE *, bool, int);
-static void print_function ( FILE *, int, function *);
+static void print_function ( FILE *, bool, int, function *, Info *);
static ReorgType_t *get_reorgtype( gimple *stmt, Info *, int);
static int num_reorgtypes( gimple *, Info *);
static bool uses_field_of_reorgtypes( gimple *, Info *);
@@ -152,7 +145,7 @@ ipa_structure_reorg ( void)
std::vector <two_trees_t> Modified_Types;
std::set <tree> Dont_Modify;
std::map <tree,TypeHolder> Type_Mod_Info;
- DEBUG("SAMPLE DEGUG\n");
+ //DEBUG("SAMPLE DEGUG\n");
//DEBUG_L( "Running ipa_structure_reorg\n");
//INDENT(2);
@@ -290,7 +283,7 @@ initial_debug_info ( Info *info)
{
if ( info->reorg_dump_file )
{
- print_program ( info->reorg_dump_file, PRINT_FORMAT, 0, info);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, false, 0, info);
}
}
@@ -299,7 +292,7 @@ final_debug_info ( Info *info)
{
if ( info->reorg_dump_file )
{
- print_program ( info->reorg_dump_file, PRINT_FORMAT, 0, info);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, false, 0, info);
}
}
@@ -488,8 +481,7 @@ reorg_analysis ( Info *info)
}
//INDENT(-2);
- //DEBUG_L("after reorg_analysis\n");
- remove_deleted_types ( info, &reorg_analysis_debug);
+ remove_deleted_types ( info, "after reorg_analysis", &reorg_analysis_debug);
if ( info->show_all_reorg_cands )
{
@@ -507,7 +499,7 @@ number_of_executions ( gimple *stmt,
struct cgraph_node *node)
{
basic_block bb = stmt->bb;
- //DEBUG_A("number_of_executions <bb %d> stmt: ", bb->index);
+ //DEBUG_A("number_of_executions:> <bb %d> stmt: ", bb->index);
//DEBUG_F(print_gimple_stmt, stderr, stmt, TDF_DETAILS);
// Check for in loop
@@ -571,7 +563,7 @@ reorg_analysis_debug ( Info *info, ReorgType *reorg )
static bool
find_decls_and_types ( Info *info)
{
- //DEBUG_L("find_decls_and_types: entered\n");
+ //DEBUG_L("find_decls_and_types:> entered\n");
detected_incompatible_syntax = false;
std::map<tree, bool> whitelisted = get_whitelisted_nodes();
@@ -614,8 +606,8 @@ find_decls_and_types ( Info *info)
if ( TREE_CODE ( canonical) != RECORD_TYPE ) continue;
// Check for incomplete types and ignore them.
if ( TYPE_SIZE ( canonical) == NULL ) continue;
- DEBUG_A( "canonical = ");
- DEBUG_F(flexible_print, stderr, canonical, 1, (dump_flags_t)0);
+ //DEBUG_A( "canonical = ");
+ //DEBUG_F(flexible_print, stderr, canonical, 1, (dump_flags_t)0);
if ( TYPE_FIELDS ( canonical) == NULL ) continue;
// The types here are highly redundant so ignore
@@ -735,8 +727,9 @@ find_decls_and_types ( Info *info)
//INDENT(-2);
}
//INDENT(-2);
- //DEBUG_L( "after Scan all types in ReorgTypes for structure fields\n");
- remove_deleted_types ( info, &initial_reorg_debug);
+ remove_deleted_types ( info,
+ "after Scan all types in ReorgTypes for structure fields",
+ &initial_reorg_debug);
// Disqualifying structures in interior to structures is optional
// (see comment at end of type escape section) but if it's not
@@ -807,7 +800,7 @@ find_decls_and_types ( Info *info)
static bool
find_decls_and_types ( Info *info)
{
- //DEBUG_L("find_decls_and_types: entered\n");
+ //DEBUG_L("find_decls_and_types:> entered\n");
// Don't keep any structure types if they aren't
// used in an array or have a pointer type (which
@@ -1027,8 +1020,9 @@ find_decls_and_types ( Info *info)
//INDENT(-2);
}
//INDENT(-2);
- //DEBUG_L( "after Scan all types in ReorgTypes for structure fields\n");
- remove_deleted_types ( info, &initial_reorg_debug);
+ remove_deleted_types ( info,
+ "after Scan all types in ReorgTypes for structure fields",
+ &initial_reorg_debug);
// Disqualifying structures in interior to structures is optional
// (see comment at end of type escape section) but if it's not
@@ -1125,11 +1119,11 @@ find_and_create_all_modified_types ( Info_t *info)
{
std::map <tree,TypeHolder> *types = info->type_mod_info;
std::deque <tree> rec_types_work_list;
- DEBUG_L("find_and_create_all_modified_types:\n");
+ //DEBUG_L("find_and_create_all_modified_types:>\n");
- DEBUG_A("At start:\n");
- DEBUG_F( dump_modified_types, stderr, info);
- INDENT(4);
+ //DEBUG_A("At start:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
+ //INDENT(4);
// Fill out the references to each type from each type
for ( auto typei = types->begin (); typei != types->end (); typei++ )
@@ -1137,9 +1131,9 @@ find_and_create_all_modified_types ( Info_t *info)
tree type = typei->first;
TypeHolder *holder = &(typei->second);
tree canonical_type = TYPE_MAIN_VARIANT ( base_type_of ( type));
- DEBUG_A( "canonical_type = ");
- DEBUG_F(flexible_print, stderr, canonical_type, 1, (dump_flags_t)0);
- INDENT(4);
+ //DEBUG_A( "canonical_type = ");
+ //DEBUG_F(flexible_print, stderr, canonical_type, 1, (dump_flags_t)0);
+ //INDENT(4);
// For each record type create an entry
for ( tree field = TYPE_FIELDS ( canonical_type);
@@ -1148,14 +1142,14 @@ find_and_create_all_modified_types ( Info_t *info)
{
tree field_type = TREE_TYPE ( field);
tree canonical_field_type = TYPE_MAIN_VARIANT ( base_type_of (field_type));
- DEBUG_A( "canonical_field_type = ");
- DEBUG_F(flexible_print, stderr, canonical_field_type, 1, (dump_flags_t)0);
+ //DEBUG_A( "canonical_field_type = ");
+ //DEBUG_F(flexible_print, stderr, canonical_field_type, 1, (dump_flags_t)0);
rec_types_work_list.push_back ( canonical_type);
if ( TREE_CODE ( canonical_field_type) == RECORD_TYPE)
{
- DEBUG_A("TREE_CODE ( canonical_field_type) == RECORD_TYPE\n");
+ //DEBUG_A("TREE_CODE ( canonical_field_type) == RECORD_TYPE\n");
auto referenced = types->find ( canonical_field_type);
gcc_assert ( referenced != types->end ());
@@ -1163,36 +1157,36 @@ find_and_create_all_modified_types ( Info_t *info)
find_in_type_vec ( &referenced->second.refed_types, canonical_type);
if ( foundi == referenced->second.refed_types.end () )
{
- DEBUG_A("referenced->second.refed_types.push_back ( canonical_type)\n");
+ //DEBUG_A("referenced->second.refed_types.push_back ( canonical_type)\n");
referenced->second.refed_types.push_back ( canonical_type);
}
}
if ( TREE_CODE ( field_type) == RECORD_TYPE )
{
- DEBUG_A("TREE_CODE ( field_type) == RECORD_TYPE\n");
+ //DEBUG_A("TREE_CODE ( field_type) == RECORD_TYPE\n");
auto foundi = find_in_type_vec ( &holder->rec_types, canonical_type);
if ( foundi == holder->rec_types.end () )
{
- DEBUG_A("holder->rec_types.push_back ( field_type)\n");
+ //DEBUG_A("holder->rec_types.push_back ( field_type)\n");
holder->rec_types.push_back ( field_type);
}
}
}
- INDENT(-4);
+ //INDENT(-4);
// Having an interior record means it can't be processed initally.
// That is because this is done bottom up starting with types
// that have no modified interior records.
if ( holder->rec_types.empty () )
{
- DEBUG_A( "rec_types_work_list <- ");
- DEBUG_F(flexible_print, stderr, canonical_type, 1, (dump_flags_t)0);
+ //DEBUG_A( "rec_types_work_list <- ");
+ //DEBUG_F(flexible_print, stderr, canonical_type, 1, (dump_flags_t)0);
rec_types_work_list.push_back ( canonical_type);
}
}
- INDENT(-4);
+ //INDENT(-4);
- DEBUG_A("Before modification setup:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ //DEBUG_A("Before modification setup:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
//
// Propagate The Modifications
@@ -1218,9 +1212,9 @@ find_and_create_all_modified_types ( Info_t *info)
auto foundtype = find_in_type_vec ( &needs_modification, canonical_field_type);
if( foundtype == needs_modification.end () )
{
- DEBUG_L("needs_modification, insert canonical_field_type %p = ", canonical_field_type);
- DEBUG_F(flexible_print, stderr, canonical_field_type, 1, (dump_flags_t)0);
- DEBUG_A(" TYPE_FIELDS = %p\n", TYPE_FIELDS(canonical_field_type));
+ //DEBUG_L("needs_modification, insert canonical_field_type %p = ", canonical_field_type);
+ //DEBUG_F(flexible_print, stderr, canonical_field_type, 1, (dump_flags_t)0);
+ //DEBUG_A(" TYPE_FIELDS = %p\n", TYPE_FIELDS(canonical_field_type));
needs_modification.push_back ( canonical_field_type);
work_list.push_back ( canonical_field_type);
}
@@ -1236,8 +1230,8 @@ find_and_create_all_modified_types ( Info_t *info)
}
}
- DEBUG_A("Before propogation:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ //DEBUG_A("Before propogation:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
// propigate
while ( !work_list.empty () )
@@ -1252,13 +1246,13 @@ find_and_create_all_modified_types ( Info_t *info)
{
tree ref_type = *ref_typei;
tree canonical_ref_type = TYPE_MAIN_VARIANT ( base_type_of (ref_type));
- DEBUG_A("ref_type %p = ", canonical_ref_type);
- DEBUG_F(flexible_print, stderr, canonical_ref_type, 1, (dump_flags_t)0);
- DEBUG_A(" TYPE_FIELDS = %p\n", TYPE_FIELDS(canonical_ref_type));
+ //DEBUG_A("ref_type %p = ", canonical_ref_type);
+ //DEBUG_F(flexible_print, stderr, canonical_ref_type, 1, (dump_flags_t)0);
+ //DEBUG_A(" TYPE_FIELDS = %p\n", TYPE_FIELDS(canonical_ref_type));
auto foundtype = find_in_type_vec ( &needs_modification, canonical_ref_type);
if ( foundtype == needs_modification.end () )
{
- DEBUG_A(" Inserted\n");
+ //DEBUG_A(" Inserted\n");
needs_modification.push_back ( canonical_ref_type);
work_list.push_back ( canonical_ref_type);
}
@@ -1275,16 +1269,16 @@ find_and_create_all_modified_types ( Info_t *info)
// Create The Modifications
- DEBUG_A("Before doing the modifications:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ //DEBUG_A("Before doing the modifications:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
// Just create the type, the fields are created afterwards
for ( auto type2modi = needs_modification.begin ();
type2modi != needs_modification.end (); type2modi++ )
{
tree type_to_modify = *type2modi;
- DEBUG_A("type_to_modify (from needs_modification) = ");
- DEBUG_F(flexible_print, stderr, type_to_modify, 1, (dump_flags_t)0);
+ //DEBUG_A("type_to_modify (from needs_modification) = ");
+ //DEBUG_F(flexible_print, stderr, type_to_modify, 1, (dump_flags_t)0);
// Create new record type
tree modified_type = lang_hooks.types.make_type (RECORD_TYPE);
//(*(info->modified_types))[ type_to_modify] = modified_type;
@@ -1301,8 +1295,8 @@ find_and_create_all_modified_types ( Info_t *info)
// Build the new pointer type fields
TYPE_NAME ( modified_type) = get_identifier ( rec_name);
}
- DEBUG_A("Before field creation:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ //DEBUG_A("Before field creation:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
// Create the fields but the types must be created in a bottom up
// manner where the types include types as elements that are below
@@ -1311,8 +1305,8 @@ find_and_create_all_modified_types ( Info_t *info)
{
tree type = rec_types_work_list.front ();
rec_types_work_list.pop_front ();
- DEBUG_A("type (rec_types_work_list.front) = ");
- DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
+ //DEBUG_A("type (rec_types_work_list.front) = ");
+ //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
//auto pairi = info->modified_types->find (type);
auto peari = find_in_vec_of_two_types ( info->modified_types, type);
//gcc_assert( peari != info->modified_types->end ());
@@ -1325,8 +1319,8 @@ find_and_create_all_modified_types ( Info_t *info)
// The sane type should be complete! (I hope)
tree sane_type = peari->first;
gcc_assert( TYPE_FIELDS ( sane_type) != NULL );
- DEBUG_A("sane_type (TYPE_FIELDS %p) = ", TYPE_FIELDS ( sane_type));
- DEBUG_F(flexible_print, stderr, sane_type, 1, (dump_flags_t)0);
+ //DEBUG_A("sane_type (TYPE_FIELDS %p) = ", TYPE_FIELDS ( sane_type));
+ //DEBUG_F(flexible_print, stderr, sane_type, 1, (dump_flags_t)0);
tree modified_type = peari->second;
tree field;
@@ -1335,22 +1329,22 @@ find_and_create_all_modified_types ( Info_t *info)
{
tree field_type = TREE_TYPE ( field);
tree new_fld_type;
- DEBUG_A("transforming field = ");
- DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0);
+ //DEBUG_A("transforming field = ");
+ //DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0);
tree canoncl_fld_type = TYPE_MAIN_VARIANT ( base_type_of (field_type));
// TBD Do I need a canonical type here instead?
//auto is_modified = info->modified_types->find ( type);
//auto is_modified = find_in_vec_of_two_types ( info->modified_types, sane_type); // ???
auto is_modified = find_in_vec_of_two_types ( info->modified_types, canoncl_fld_type);
- DEBUG_A("is_modified = %s\n", is_modified != info->modified_types->end () ? "T" : "F");
+ //DEBUG_A("is_modified = %s\n", is_modified != info->modified_types->end () ? "T" : "F");
if ( is_modified != info->modified_types->end () )
{
if ( POINTER_TYPE_P ( field_type))
{
ReorgType_t *ri = get_reorgtype_info ( canoncl_fld_type, info);
int levels = number_of_levels ( field_type);
- DEBUG_A("ri = %p, levels = %d\n", ri, levels);
+ //DEBUG_A("ri = %p, levels = %d\n", ri, levels);
if ( ri == NULL )
{
new_fld_type = make_multilevel ( is_modified->second, levels);
@@ -1375,12 +1369,15 @@ find_and_create_all_modified_types ( Info_t *info)
FIELD_DECL, DECL_NAME (field), new_fld_type);
DECL_CONTEXT ( new_decl) = modified_type;
- DEBUG_A("new_fld_type = ");
- DEBUG_F(flexible_print, stderr, new_fld_type, 1, (dump_flags_t)0);
- DEBUG_A("new_decl = ");
- DEBUG_F(flexible_print, stderr, new_decl, 1, (dump_flags_t)0);
-
+ //DEBUG_A("new_fld_type = ");
+ //DEBUG_F(flexible_print, stderr, new_fld_type, 1, (dump_flags_t)0);
+ //DEBUG_A("new_decl = ");
+ //DEBUG_F(flexible_print, stderr, new_decl, 1, (dump_flags_t)0);
+
+ // Doesn't actually seem to be needed !?!
+ #if 0
layout_decl ( new_decl, 0);
+ #endif
// We might be missing a bunch of attributes (see
// tree-nested.c:899) But we seem without without them!
@@ -1401,11 +1398,42 @@ find_and_create_all_modified_types ( Info_t *info)
TYPE_FIELDS ( modified_type) = field;
}
- DEBUG_A("Before lay_type:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ //DEBUG_A("Before lay_type:\n");
+ //DEBUG_F( dump_modified_types, stderr, false, info);
// Lay it out
+ #if 0
+
+ #if 0
layout_type ( modified_type);
+ #else
+ // from stor-layout.c:finish_builtin_struct (NOPE!)
+ TYPE_STUB_DECL ( modified_type) = TYPE_NAME ( modified_type);
+ layout_decl ( TYPE_NAME ( modified_type), 0);
+ #endif
+
+ #else
+
+ // From ubsan.c:ubsan_get_type_descriptor_type
+ // This doesn't break anything but it doesn't help either!
+
+ // create a decl for the type
+ tree type_decl = build_decl ( UNKNOWN_LOCATION, TYPE_DECL,
+ //get_identifier ("__ubsan_type_descriptor")???,
+ TYPE_NAME ( modified_type),
+ modified_type);
+
+ //DECL_IGNORED_P (type_decl) = 1; // ???
+ //DECL_ARTIFICIAL (type_decl) = 1; // ???
+
+ // TYPE_NAME ( modified_type) = type_decl; // ??? What the FUCK!
+
+ TYPE_STUB_DECL ( modified_type) = type_decl;
+
+ //TYPE_ARTIFICIAL ( modified_type) = 1; // ???
+
+ layout_type ( modified_type);
+ #endif
TypeHolder *holder = &(types->find ( sane_type)->second);
// Add new types to the work list if possible
@@ -1434,24 +1462,53 @@ find_and_create_all_modified_types ( Info_t *info)
}
}
DEBUG_A("End results:\n");
- DEBUG_F( dump_modified_types, stderr, info);
+ DEBUG_F( dump_modified_types, stderr, true, info);
}
static std::vector<tree>::iterator
find_in_type_vec ( std::vector<tree> *types, tree type)
{
+ INDENT(2);
for ( auto looki = types->begin (); looki != types->end (); looki++)
{
tree look = *looki;
if ( same_type_p ( look, type) ) return looki;
}
+ INDENT(-2);
return types->end ();
}
+void
+dump_record (FILE *file, tree record_type, bool extra_details, Info_t *info)
+{
+ //DEBUG_A("dump_record:>\n");
+ tree field;
+ flexible_print ( file, record_type, 1, (dump_flags_t)0);
+ for ( field = TYPE_FIELDS ( record_type);
+ field; field = DECL_CHAIN ( field))
+ {
+ fprintf ( file, " ");
+ flexible_print ( file, field, 1, (dump_flags_t)0);
+ if ( extra_details )
+ {
+ tree off = DECL_FIELD_OFFSET ( field);
+ if ( off )
+ {
+ fprintf ( file, " ");
+ flexible_print ( file, off, 1, (dump_flags_t)0);
+ }
+ else
+ {
+ fprintf ( file, " (nil)\n");
+ }
+ }
+ }
+}
+
static void
-dump_modified_types (FILE *file, Info_t *info)
+dump_modified_types (FILE *file, bool extra_details, Info_t *info)
{
- DEBUG_A("");
+ //DEBUG_A("");
fprintf ( file, "dump_modified_types:%s\n",
info->modified_types->begin () == info->modified_types->end ()
? " (empty)" : "");
@@ -1461,26 +1518,60 @@ dump_modified_types (FILE *file, Info_t *info)
tree field;
tree orig_type = modifi->first;
tree new_type = modifi->second;
- DEBUG_A("");
+ //DEBUG_A("");
fprintf ( file, " %p, ", TYPE_FIELDS ( orig_type));
+ #if 1
+ dump_record (file, orig_type, extra_details, info);
+ #else
flexible_print ( file, orig_type, 1, (dump_flags_t)0);
for ( field = TYPE_FIELDS ( orig_type);
field; field = DECL_CHAIN ( field))
{
- DEBUG_A("");
+ //DEBUG_A("");
fprintf ( file, " ", TYPE_FIELDS ( new_type));
flexible_print ( file, field, 1, (dump_flags_t)0);
+ if ( extra_details )
+ {
+ tree off = DECL_FIELD_OFFSET ( field);
+ if ( off )
+ {
+ fprintf ( file, " ");
+ flexible_print ( file, off, 1, (dump_flags_t)0);
+ }
+ else
+ {
+ fprintf ( file, " (nil)\n");
+ }
+ }
}
- DEBUG_A("");
+ #endif
+ //DEBUG_A("");
fprintf ( file, " %p, ", TYPE_FIELDS ( new_type));
+ #if 1
+ dump_record (file, new_type, extra_details, info);
+ #else
flexible_print ( file, new_type, 1, (dump_flags_t)0);
for ( field = TYPE_FIELDS ( new_type);
field; field = DECL_CHAIN ( field))
{
- DEBUG_A("");
+ //DEBUG_A("");
fprintf ( file, " ");
flexible_print ( file, field, 1, (dump_flags_t)0);
+ if ( extra_details )
+ {
+ tree off = DECL_FIELD_OFFSET ( field);
+ if ( off )
+ {
+ fprintf ( file, " ");
+ flexible_print ( file, off, 1, (dump_flags_t)0);
+ }
+ else
+ {
+ fprintf ( file, " (nil)\n");
+ }
+ }
}
+ #endif
}
}
@@ -1499,13 +1590,13 @@ possibly_modify_pointer_types ( tree type, Info_t *info)
if ( TREE_CODE( type) != RECORD_TYPE )
return false;
- DEBUG_L("possibly_modify_pointer_types: ");
- DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
- INDENT(4);
+ //DEBUG_L("possibly_modify_pointer_types:> ");
+ //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
+ //INDENT(4);
if ( TYPE_SIZE ( type) == NULL || TYPE_FIELDS ( type) == NULL)
{
- DEBUG_A("Incomplete type\n");
+ //DEBUG_A("Incomplete type\n");
INDENT(-4);
return false;
}
@@ -1513,14 +1604,14 @@ possibly_modify_pointer_types ( tree type, Info_t *info)
// NOPE
if ( info->modified_types->find ( type) != info->modified_types->end () )
{
- DEBUG_A("Already modified\n");
- INDENT(-4);
+ //DEBUG_A("Already modified\n");
+ //INDENT(-4);
return true;
}
if ( info->dont_modify->find ( type) != info->dont_modify->end () )
{
- DEBUG_A("Marked to not modify\n");
- INDENT(-4);
+ //DEBUG_A("Marked to not modify\n");
+ //INDENT(-4);
return false;
}
for ( tree field = TYPE_FIELDS ( type);
@@ -1531,9 +1622,9 @@ possibly_modify_pointer_types ( tree type, Info_t *info)
tree canonical_field_type = TYPE_MAIN_VARIANT ( base_type_of (field_type));
bool pointer = POINTER_TYPE_P ( field_type);
bool record = TREE_CODE( canonical_field_type) == RECORD_TYPE;
- DEBUG_A("Field: ");
- DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0);
- DEBUG_A(" pointer %s, record %s\n", pointer ? "T" : "F", record ? "T" :"F");
+ //DEBUG_A("Field: ");
+ //DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0);
+ //DEBUG_A(" pointer %s, record %s\n", pointer ? "T" : "F", record ? "T" :"F");
if ( pointer && record )
{
bool is_reorg = is_reorg_type ( canonical_field_type, info);
@@ -1643,23 +1734,53 @@ possibly_modify_pointer_types ( tree type, Info_t *info)
{
info->dont_modify->insert ( type);
}
- DEBUG_A("Was %smodidied\n", modified ? "" : "not ");
- INDENT(-4);
+ //DEBUG_A("Was %smodidied\n", modified ? "" : "not ");
+ //INDENT(-4);
return modified;
}
#endif
tree
-find_modified ( tree type, Info_t *info )
+find_modified ( tree type,
+ #if ALLOW_REVERSE
+ bool reverse,
+ #endif
+ Info_t *info )
{
- DEBUG_A("find_modified: ");
+ DEBUG_A("find_modified:> ");
DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
- auto resulti = find_in_vec_of_two_types ( info->modified_types, type);
- if ( resulti == info->modified_types->end () )
+ // Use canonical type
+ tree canonical = TYPE_MAIN_VARIANT ( base_type_of ( type));
+ tree ret_val = NULL;
+ #if ALLOW_REVERSE
+ if ( reverse )
{
- return NULL;
+ auto resulti = find_in_vec_of_two_types_2nd ( info->modified_types, canonical);
+ if ( resulti != info->modified_types->end () )
+ {
+ ret_val = resulti->first; // ???
+ }
+ }
+ else
+ {
+ auto resulti = find_in_vec_of_two_types ( info->modified_types, canonical);
+ if ( resulti != info->modified_types->end () )
+ {
+ ret_val = resulti->second;
+ }
}
- return resulti->second;
+ #else
+ auto resulti = find_in_vec_of_two_types ( info->modified_types, canonical);
+ if ( resulti != info->modified_types->end () )
+ {
+ ret_val resulti->second;
+ }
+ #endif
+
+ DEBUG_A(" returns... ");
+ DEBUG_F(flexible_print, stderr, ret_val, 1, (dump_flags_t)0);
+
+ return ret_val;
}
bool
@@ -1668,7 +1789,7 @@ new_contains_a_modified ( gimple *stmt, tree *lhs_mod, tree *rhs_mod, Info_t *in
bool modified = false;
*lhs_mod = NULL;
*rhs_mod = NULL;
- DEBUG_A("new_contains_a_modified: ");
+ DEBUG_FLA("new_contains_a_modified:> ");
DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
INDENT(2);
// For an assign check both sides component refs.
@@ -1692,7 +1813,11 @@ new_contains_a_modified ( gimple *stmt, tree *lhs_mod, tree *rhs_mod, Info_t *in
// modified.
if ( l_deepest_type )
{
- if ( find_modified ( l_deepest_type, info) )
+ if ( find_modified ( l_deepest_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info) )
{
*lhs_mod = l_deepest_type;
modified = true;
@@ -1700,7 +1825,11 @@ new_contains_a_modified ( gimple *stmt, tree *lhs_mod, tree *rhs_mod, Info_t *in
}
if ( rhs
&& (r_deepest_type = find_deepest_comp_ref_type ( rhs))
- && find_modified ( r_deepest_type, info) )
+ && find_modified ( r_deepest_type,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info) )
{
*rhs_mod = r_deepest_type;
modified = true;
@@ -1711,10 +1840,14 @@ new_contains_a_modified ( gimple *stmt, tree *lhs_mod, tree *rhs_mod, Info_t *in
}
tree
-contains_a_modified ( gimple *stmt, Info_t *info )
+contains_a_modified ( gimple *stmt,
+ #if ALLOW_REVERSE
+ bool reverse, // reverse sense of modification
+ #endif
+ Info_t *info )
{
- DEBUG_A("contains_a_modified: ");
- DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
+ //DEBUG_A("contains_a_modified:> ");
+ //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
// For an assign check both sides component refs.
if ( gimple_code ( stmt) == GIMPLE_ASSIGN )
{
@@ -1736,7 +1869,11 @@ contains_a_modified ( gimple *stmt, Info_t *info )
// modified.
if ( l_deepest_type )
{
- if ( find_modified ( l_deepest_type, info) )
+ if ( find_modified ( l_deepest_type,
+ #if ALLOW_REVERSE
+ reverse,
+ #endif
+ info) )
return l_deepest_type;
// Just having a componet ref means we don't
// have to look at the other side
@@ -1744,14 +1881,18 @@ contains_a_modified ( gimple *stmt, Info_t *info )
}
if ( rhs
&& (r_deepest_type = find_deepest_comp_ref_type ( rhs))
- && find_modified ( r_deepest_type, info) )
+ && find_modified ( r_deepest_type,
+ #if ALLOW_REVERSE
+ reverse,
+ #endif
+ info) )
return r_deepest_type;
}
// Otherwise,
return NULL;
}
-static tree
+tree
find_deepest_comp_ref_type ( tree op )
{
if ( op == NULL ) return NULL;
@@ -1777,7 +1918,7 @@ add_reorg_type (
{ 0, del, tmv_type, NULL, NULL, false, false, false,
{ 0}, { 0}, { 0, 0, 0, NULL, 0.0, 0.0, false}};
- //DEBUG_L("add_reorg_type: ");
+ //DEBUG_L("add_reorg_type:> ");
//DEBUG_F(flexible_print, stderr, base, 1, (dump_flags_t)0);
info->reorg_type->push_back ( rt);
#if !USE_ESCAPE_ANALYSIS
@@ -1794,7 +1935,7 @@ disqualify_struct_in_struct_or_union ( Info *info)
varpool_node *var;
std::set<tree> typeset;
- //DEBUG_L( "In disqualify_struct_in_struct_or_union\n");
+ //DEBUG_L( "disqualify_struct_in_struct_or_union:>\n");
//INDENT(2);
FOR_EACH_VARIABLE ( var)
@@ -1848,8 +1989,8 @@ disqualify_struct_in_struct_or_union ( Info *info)
}
//INDENT(-2);
}
- //DEBUG_L("after disqualify_struct_in_struct_or_union\n");
remove_deleted_types ( info,
+ "after disqualify_struct_in_struct_or_union",
&disqualify_struct_in_struct_or_union_debug);
}
@@ -1880,7 +2021,7 @@ disq_str_in_str_or_union_helper ( tree type,
std::set<tree> *typeset,
Info *info )
{
- //DEBUG_L( "In disq_str_in_str_or_union_helper (possibele deletes)\n");
+ //DEBUG_L( "disq_str_in_str_or_union_helper:> (possibele deletes)\n");
//INDENT(2);
if ( typeset->find ( type) != typeset->end ()) return;
@@ -2048,8 +2189,9 @@ transformation_legality ( Info *info)
// nonzero constant. Disqualify any typeas this happens with.
}
- //DEBUG_L("after transformation_legality\n");
- remove_deleted_types ( info, &transformation_legality_debug);
+ remove_deleted_types ( info,
+ "after transformation_legality",
+ &transformation_legality_debug);
return !info->reorg_type->empty ();
}
@@ -2068,12 +2210,36 @@ static void
reorg_common_middle_code ( Info *info)
{
if ( BYPASS_TRANSFORM ) return;
+ #if 0
modify_declarations( info);
+ #endif
+ ;
}
static void
modify_declarations ( Info *info)
{
+ modify_global_declarations (info);
+}
+
+// Not parctical!
+#if 0
+void
+modify_local_declarations ( Info *info)
+{
+ ;
+}
+
+void
+modify_parameter_declarations ( Info *info)
+{
+ ;
+}
+#endif
+
+void
+modify_global_declarations ( Info *info)
+{
// For the moment we ignore initializations assuming
// all potential reorg types that had initialized
// arrays were disqualified. Note, it's the way
@@ -2161,7 +2327,7 @@ modify_declarations ( Info *info)
static void
disqualify_all_reorgtypes_of ( gimple *stmt, int num, Info *info)
{
- //DEBUG_L("disqualify %d reorgtypes of: ", num);
+ //DEBUG_L("disqualify %d reorgtypes of:> ", num);
//DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
if ( info->show_all_reorg_cands_in_detail )
{
@@ -2344,11 +2510,34 @@ reverse_args( tree args )
std::vector<two_trees_t>::iterator
find_in_vec_of_two_types ( std::vector<two_trees_t> *types, tree type)
{
+ INDENT(2);
for ( auto looki = types->begin (); looki != types->end (); looki++)
{
tree look = looki->first;
- if ( same_type_p ( look, type) ) return looki;
+ if ( same_type_p ( look, type) )
+ {
+ INDENT(-2);
+ return looki;
+ }
}
+ INDENT(-2);
+ return types->end ();
+}
+
+std::vector<two_trees_t>::iterator
+find_in_vec_of_two_types_2nd ( std::vector<two_trees_t> *types, tree type)
+{
+ INDENT(2);
+ for ( auto looki = types->begin (); looki != types->end (); looki++)
+ {
+ tree look = looki->second;
+ if ( same_type_p ( look, type) )
+ {
+ INDENT(-2);
+ return looki;
+ }
+ }
+ INDENT(-2);
return types->end ();
}
@@ -2370,23 +2559,23 @@ tree prev_type;
tree
make_multilevel ( tree base_type, int levels_indirection)
{
- DEBUG_A("make_multilevel %d levels of ", levels_indirection);
- DEBUG_F( flexible_print, stderr, base_type, 1, (dump_flags_t)0);
- INDENT(4);
+ //DEBUG_A("make_multilevel;> %d levels of ", levels_indirection);
+ //DEBUG_F( flexible_print, stderr, base_type, 1, (dump_flags_t)0);
+ //INDENT(4);
if ( levels_indirection == 0 )
{
- INDENT(-4);
- DEBUG_A("returns: ");
- DEBUG_F( flexible_print, stderr, base_type, 1, (dump_flags_t)0);
+ //INDENT(-4);
+ //DEBUG_A("returns: ");
+ //DEBUG_F( flexible_print, stderr, base_type, 1, (dump_flags_t)0);
return base_type;
}
else
{
tree lower = make_multilevel ( base_type, levels_indirection - 1);
tree returns = build_pointer_type ( lower);
- INDENT(-4);
- DEBUG_A("returns: ");
- DEBUG_F( flexible_print, stderr, returns, 1, (dump_flags_t)0);
+ //INDENT(-4);
+ //DEBUG_A("returns: ");
+ //DEBUG_F( flexible_print, stderr, returns, 1, (dump_flags_t)0);
return returns;
}
}
@@ -2394,7 +2583,7 @@ make_multilevel ( tree base_type, int levels_indirection)
static bool
modify_func_decl_core ( struct function *func, Info *info)
{
- //DEBUG_L("BEFORE modify_func_decl_core:\n");
+ //DEBUG_L("modify_func_decl_core:>\n");
//INDENT(4);
//DEBUG_A("func->decl = %p, ", func->decl);
//DEBUG_F( flexible_print, stderr, func->decl, 1, (dump_flags_t)0);
@@ -2456,123 +2645,97 @@ modify_func_decl_core ( struct function *func, Info *info)
}
// Returns true if a modification occurred
-#if 0
-// Dubious version
bool
modify_decl_core ( tree *location, Info *info)
{
- DEBUG_L("before modify_decl_core: ");
- DEBUG_F( flexible_print, stderr, *location, 1, (dump_flags_t)0);
- tree type = *location;
- DEBUG_A("type = ");
- DEBUG_F( flexible_print, stderr, type, 0, (dump_flags_t)0);
- tree base = base_type_of ( type);
- DEBUG_A(", base = ");
- DEBUG_F( flexible_print, stderr, base, 1, (dump_flags_t)0);
- ReorgType_t *ri = get_reorgtype_info ( base, info);
- if ( ri == NULL )
- {
- return false;
- }
-
- // array case -- not doing non-dynamically
- // allocated arrays yet so this case won't
- // currently occur
-
- // borrowed from wrangle_ssa_type
- tree prev_type;
- int levels;
- for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ )
- {
- prev_type = type;
- type = TREE_TYPE ( prev_type);
- DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
- }
- // TBD might use build_pointer_type to build new type for *(N)reorg_type
- // to *(N-1)ri->pointer_rep. NOTE, there is something similar implemented
- // elsewhere but the checks were are all for levels == 1! Yikes!
- // Fakes this for levels == 1
- if ( levels == 0) // How did this test ever work???? It didn't
- //if ( levels == 1)
- {
- DEBUG_L( "LEVEL ONE\n");
- //modify_ssa_name_type ( side, ri->pointer_rep);
- gcc_assert ( TYPE_MAIN_VARIANT ( ri->pointer_rep));
- //TREE_TYPE ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
- TREE_TYPE(*location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
- }
- else
- {
- DEBUG_L( "LEVEL > ONE\n");
- gcc_assert(0);
- }
-
- if ( DECL_INITIAL ( *location) != NULL )
- {
- // Note this assumes the levels code above is not general
- DECL_INITIAL ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
- }
-
- relayout_decl ( *location);
-
- DEBUG_L(" after modify_decl_core");
- DEBUG_F( flexible_print, stderr, *location, 1, (dump_flags_t)0);
- return true;
-}
-#else
-// Nodubious version
-bool
-modify_decl_core ( tree *location, Info *info)
-{
- //DEBUG_L("before modify_decl_core: ");
+ //DEBUG_L("modify_decl_core:> ");
//DEBUG_F( flexible_print, stderr, *location, 1, (dump_flags_t)0);
- //tree type = *location;
tree type = TREE_TYPE ( *location);
//DEBUG_A("type = ");
//DEBUG_F( flexible_print, stderr, type, 0, (dump_flags_t)0);
+
tree base = base_type_of ( type);
+
//DEBUG_A(", base = ");
//DEBUG_F( flexible_print, stderr, base, 1, (dump_flags_t)0);
+
+ #if 1
+ // Look for a modified type
+ tree modified_to = find_modified ( base,
+ #if ALLOW_REVERSE
+ false,
+ #endif
+ info);
+ bool use_mod = false;
+ #endif
+
ReorgType_t *ri = get_reorgtype_info ( base, info);
if ( ri == NULL )
{
+ #if 1
+ use_mod = modified_to != NULL;
+ if( !use_mod ) return false;
+ #endif
return false;
}
- // array case -- not doing non-dynamically
- // allocated arrays yet so this case won't
- // currently occur
-
- // borrowed from wrangle_ssa_type
tree prev_type;
- int levels;
- for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ )
+ int levels = number_of_levels ( type);
+
+ #if 1
+ if ( use_mod )
{
- prev_type = type;
- type = TREE_TYPE ( prev_type);
- //DEBUG_A( "prev_type: %p, type: %p\n", prev_type, type);
+ if ( levels == 0 )
+ {
+ TREE_TYPE(*location) = TYPE_MAIN_VARIANT ( modified_to);
+ }
+ else
+ {
+ TREE_TYPE(*location) = make_multilevel ( modified_to, levels);
+ }
+ }
+ else
+ {
+ // TBD, I have some doubt that this actually works right for more
+ // that one level... It's not that make_multilevel is wrong, it's
+ // that it seems like it will build one too many levels because
+ // the arguement is off by one. Remember that transforming to
+ // reorg pointer strips off one level of indirection!
+
+ // Fakes this for levels == 1
+ if ( levels == 0)
+ {
+ //DEBUG_A("Not a pointer, don't modify it!\n");
+ return false;
+ }
+ // This also happens with other similar uses of make_multilevel.
+ if ( levels == 1)
+ {
+ //DEBUG_A( "LEVEL ONE\n");
+ gcc_assert ( TYPE_MAIN_VARIANT ( ri->pointer_rep));
+ TREE_TYPE(*location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
+ }
+ else
+ {
+ //DEBUG_L( "LEVEL > ONE\n");
+ TREE_TYPE(*location) = make_multilevel ( ri->pointer_rep, levels);
+ }
}
- // TBD might use build_pointer_type to build new type for *(N)reorg_type
- // to *(N-1)ri->pointer_rep
+
+ #else
// Fakes this for levels == 1
if ( levels == 0)
{
//DEBUG_A("Not a pointer, don't modify it!\n");
return false;
}
- // TBD the upper code fails and it shouldn't. Debug and fix this.
// This also happens with other similar uses of make_multilevel.
- #if 0
- TREE_TYPE(*location) = make_multilevel ( ri->pointer_rep, levels);
- #else
if ( levels == 1)
{
//DEBUG_A( "LEVEL ONE\n");
- //modify_ssa_name_type ( side, ri->pointer_rep);
gcc_assert ( TYPE_MAIN_VARIANT ( ri->pointer_rep));
- //TREE_TYPE ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
TREE_TYPE(*location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
}
else
@@ -2582,25 +2745,42 @@ modify_decl_core ( tree *location, Info *info)
}
#endif
+ #if 1
+ // I'm not sure what this does!
+ if ( use_mod )
+ {
+ if ( DECL_INITIAL ( *location) != NULL )
+ {
+ DECL_INITIAL ( *location) = TYPE_MAIN_VARIANT ( modified_to);
+ }
+ }
+ else
+ if ( DECL_INITIAL ( *location) != NULL )
+ {
+ // Note this assumes the levels code above is not general
+ DECL_INITIAL ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
+ }
+ #else
if ( DECL_INITIAL ( *location) != NULL )
{
// Note this assumes the levels code above is not general
DECL_INITIAL ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
}
+ #endif
relayout_decl ( *location);
//DEBUG_L(" after modify_decl_core");
//DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0);
//DEBUG("\n");
+
return true;
}
-#endif
void
delete_reorgtype ( ReorgType_t *rt, Info *info )
{
- //DEBUG_L( "delete_reorgtype( %s ):", type_name_to_str( TYPE_NAME( rt->gcc_type)));
+ //DEBUG_L( "delete_reorgtype( %s ):>", type_name_to_str( TYPE_NAME( rt->gcc_type)));
if ( !rt->delete_me )
{
//DEBUG( "TO DELETE\n");
@@ -2614,7 +2794,7 @@ delete_reorgtype ( ReorgType_t *rt, Info *info )
void
undelete_reorgtype ( ReorgType_t *rt, Info *info )
{
- //DEBUG_L( "undelete_reorgtype( %s ): ", type_name_to_str( TYPE_NAME( rt->gcc_type)));
+ //DEBUG_L( "undelete_reorgtype( %s ):> ", type_name_to_str( TYPE_NAME( rt->gcc_type)));
if ( rt->delete_me )
{
//DEBUG( "UNDELETE\n");
@@ -2630,7 +2810,7 @@ undelete_reorgtype ( ReorgType_t *rt, Info *info )
static ReorgTransformation
reorg_recognize_ret_action( ReorgTransformation val, unsigned ln)
{
- #if DEBUGGING && 0
+ #if DEBUGGING && 1
fprintf ( stderr, "L# %4d: %*s returns %s\n",
ln, debug_indenting, "", reorgtrans_to_str (val));
#endif
@@ -2640,27 +2820,27 @@ reorg_recognize_ret_action( ReorgTransformation val, unsigned ln)
ReorgTransformation
reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
{
- DEBUG_L ( "ReorgTransformation reorg_recognize for: ");
+ DEBUG_FLA ( "ReorgTransformation reorg_recognize for:> ");
DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
INDENT(2);
switch ( gimple_code( stmt) )
{
case GIMPLE_ASSIGN:
{
- DEBUG_L("GIMPLE_ASSIGN:\n");
+ DEBUG_LA ( "GIMPLE_ASSIGN:\n");
tree lhs = gimple_assign_lhs ( stmt);
enum tree_code rhs_code = gimple_assign_rhs_code ( stmt);
if ( gimple_assign_single_p ( stmt) )
{
- DEBUG_L("gimple_assign_single_p() = true\n");
+ DEBUG_LA ("gimple_assign_single_p() = true\n");
INDENT(2);
tree rhs = gimple_assign_rhs1 ( stmt);
enum ReorgOpTrans lhs_op = recognize_op ( lhs, true, info);
switch ( lhs_op )
{
case ReorgOpT_Pointer: // "a"
- DEBUG_L("case ReorgOpT_Pointer\n");
+ DEBUG_LA ( "case ReorgOpT_Pointer\n");
INDENT(-4);
switch ( recognize_op ( rhs, true, info) )
{
@@ -2695,7 +2875,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Struct: // "s"
- DEBUG_L("case ReorgOpT_Struct\n");
+ DEBUG_LA ( "case ReorgOpT_Struct\n");
INDENT(-4);
switch ( recognize_op ( rhs, true, info) )
{
@@ -2712,7 +2892,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Deref: // "*a"
- DEBUG_L("case ReorgOpT_Deref\n");
+ DEBUG_LA ( "case ReorgOpT_Deref\n");
INDENT(-4);
switch ( recognize_op ( rhs, true, info) )
{
@@ -2724,7 +2904,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
return REORG_RECOG_RET_ACT ( Not_Supported);
}
case ReorgOpT_Array: // "x[i]"
- DEBUG_L("case ReorgOpT_Array\n");
+ DEBUG_LA ("case ReorgOpT_Array\n");
INDENT(-4);
switch ( recognize_op ( rhs, true, info) )
{
@@ -2738,7 +2918,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case ReorgOpT_Temp: // t
case ReorgOpT_Scalar: // "z"
{
- DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Temp ? "Temp" : "Scalar");
+ DEBUG_LA ("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Temp ? "Temp" : "Scalar");
INDENT(-4);
switch ( recognize_op( rhs, true, info) )
{
@@ -2762,8 +2942,8 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
case ReorgOpT_Indirect: // "a->f"
case ReorgOpT_AryDir: // "x[i].f"
{
- //DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Indirect ? "Indirect" : "AryDir");
- //INDENT(-4);
+ DEBUG_LA ("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Indirect ? "Indirect" : "AryDir");
+ INDENT(-4);
switch ( recognize_op ( rhs, true, info) )
{
case ReorgOpT_Cst: // k
@@ -2792,23 +2972,23 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
return REORG_RECOG_RET_ACT ( Not_Supported);
} // switch ( recognize_op ( lhs, true, info) )
} else {
- DEBUG_L("gimple_assign_single_p() = false\n");
+ DEBUG_LA("gimple_assign_single_p() = false\n");
INDENT(2);
tree op1 = gimple_assign_rhs1 ( stmt);
tree op2 = gimple_assign_rhs2 ( stmt);
- DEBUG_L("op1 = %p, op2 = %p\n", op1, op2);
+ DEBUG_A("op1 = %p, op2 = %p\n", op1, op2);
DEBUG_A("");
DEBUG_F( flexible_print, stderr, op1, 1, TDF_DETAILS);
if ( CONVERT_EXPR_CODE_P ( gimple_assign_rhs_code ( stmt)))
- {
- DEBUG_L("CONVERT_EXPR_CODE_P (...)\n");
+ {
+ DEBUG_LA("CONVERT_EXPR_CODE_P (...)\n");
INDENT(-4);
return REORG_RECOG_RET_ACT ( ReorgT_Convert);
}
if ( gimple_assign_rhs3 ( stmt) != NULL )
{
- DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n");
+ DEBUG_LA ("gimple_assign_rhs3 ( stmt) != NULL\n");
INDENT(-4);
return REORG_RECOG_RET_ACT ( Not_Supported);
}
@@ -2819,7 +2999,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
( (POINTER_TYPE_P ( TREE_TYPE( op1)) && integer_zerop ( op2))
|| (POINTER_TYPE_P ( TREE_TYPE( op2)) && integer_zerop ( op1)))
&& ( integer_zerop ( op1) || integer_zerop ( op2) );
- DEBUG_L("zero_case = %s\n", zero_case ? "true" : "false" );
+ DEBUG_LA ("zero_case = %s\n", zero_case ? "true" : "false" );
INDENT(-4);
switch ( rhs_code )
{
@@ -2846,7 +3026,7 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
}
case GIMPLE_COND: // Similar to assign cases
{
- DEBUG_L("GIMPLE_COND:\n");
+ DEBUG_LA ("GIMPLE_COND:\n");
INDENT(-2);
//tree op1 = gimple_assign_rhs1 ( stmt);
//tree op2 = gimple_assign_rhs2( stmt);
@@ -2878,14 +3058,14 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
}
case GIMPLE_CALL:
{
- DEBUG_L("GIMPLE_CALL:\n");
+ DEBUG_LA("GIMPLE_CALL:\n");
struct cgraph_edge *edge = node->get_edge ( stmt);
gcc_assert( edge);
- DEBUG_L("called function %s gimple_body\n",
+ DEBUG_A("called function %s gimple_body\n",
edge->callee->has_gimple_body_p() ? "has a" : "has no");
- DEBUG_L("called function inline_to %s\n",
+ DEBUG_A("called function inline_to %s\n",
edge->callee->inlined_to ? "true" : "false");
- DEBUG_L("called function external %s\n",
+ DEBUG_A("called function external %s\n",
edge->callee->get_partitioning_class() == SYMBOL_EXTERNAL ? "true" : "false");
INDENT(-2);
@@ -2910,12 +3090,12 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info )
}
break;
case GIMPLE_RETURN:
- DEBUG_L("GIMPLE_RETURN:\n");
+ DEBUG_LA ("GIMPLE_RETURN:\n");
INDENT(-2);
return REORG_RECOG_RET_ACT ( ReorgT_Return);
break;
default:
- DEBUG_L ( "didn't support: ");
+ DEBUG_LA ( "didn't support: ");
DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
DEBUG( "\n");
INDENT(-2);
@@ -2972,12 +3152,12 @@ reorg_forbidden ( gimple *stmt, Info *info )
}
void
-remove_deleted_types ( Info *info, ReorgFn reorg_fn)
+remove_deleted_types ( Info *info, char *where, ReorgFn reorg_fn)
{
- //DEBUG_L( "remove_deleted_types: %d to delete of %d types\n", info->num_deleted, info->reorg_type->size ());
+ //DEBUG_LA( "remove_deleted_types:> %d to delete of %d types\n", info->num_deleted, info->reorg_type->size ());
if ( info->show_delete )
{
- fprintf ( info->reorg_dump_file, "DELETING REORG TYPES:\n");
+ fprintf ( info->reorg_dump_file, "DELETING REORG TYPES (%s):\n", where);
}
if ( info->num_deleted > 0 )
@@ -3032,7 +3212,8 @@ recognize_op_ret_action ( enum ReorgOpTrans e )
enum ReorgOpTrans
recognize_op ( tree op, bool lie, Info *info)
{
- DEBUG_L("recognize_op: ");
+ DEBUG_LA("\n");
+ DEBUG_A("recognize_op:> ");
DEBUG_F( flexible_print, stderr, op, 1, TDF_DETAILS);
enum tree_code op_code = TREE_CODE ( op);
DEBUG_A("opcode = %s\n", code_str( op_code));
@@ -3062,15 +3243,15 @@ recognize_op ( tree op, bool lie, Info *info)
}
tree type = TREE_TYPE ( op);
- //DEBUG_A("type: ");
- //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
+ DEBUG_A ( "type: ");
+ DEBUG_F ( flexible_print, stderr, type, 1, (dump_flags_t)0);
// This type bases approach seems like crap.
// I'm turning it off to see what breaks.
#if 0
if ( type != NULL && POINTER_TYPE_P (type) )
{
- //DEBUG_L("POINTER_TYPE_P (type) = true\n");
+ DEBUG_L("POINTER_TYPE_P (type) = true\n");
bool a_reorg = is_reorg_type ( type, info);
if ( a_reorg || !lie )
{
@@ -3142,7 +3323,7 @@ recognize_op ( tree op, bool lie, Info *info)
{
case ADDR_EXPR:
{
- //DEBUG_L("op_code == ADDR_EXPR\n");
+ DEBUG_LA("op_code == ADDR_EXPR\n");
if ( inner_op0_code == ARRAY_REF )
{
bool a_reorg = is_reorg_type ( inner_op0, info);
@@ -3165,37 +3346,50 @@ recognize_op ( tree op, bool lie, Info *info)
}
case COMPONENT_REF:
{
- DEBUG_L("process: COMPONENT_REF\n");
+ DEBUG_LA ( "process... COMPONENT_REF\n");
tree inner_op1 = TREE_OPERAND( op, 1);
enum tree_code inner_op1_code = TREE_CODE ( inner_op1);
- DEBUG_L("inner_op1 = ");
- DEBUG_F(flexible_print, stderr, inner_op1, 0, (dump_flags_t)0);
- DEBUG(", TREE_CODE = %s\n", code_str( inner_op1_code));
+ DEBUG_A ( "inner_op1 = ");
+ DEBUG_F ( flexible_print, stderr, inner_op1, 0, (dump_flags_t)0);
+ DEBUG ( ", TREE_CODE = %s\n", code_str( inner_op1_code));
// Note, a reorg type can only occurr at the bottom or
// the top, that is "rt.a.b..." or "a.b...z.rt".
if ( tree deep_type = multilevel_component_ref ( op) )
{
- DEBUG_L("Is multilevel component ref: deep_type is ");
- DEBUG_F(flexible_print, stderr, deep_type, 1, (dump_flags_t)0);
+ DEBUG_LA ( "Is multilevel component ref: deep_type is ");
+ DEBUG_F ( flexible_print, stderr, deep_type, 1, (dump_flags_t)0);
+
+ tree base_type = base_type_of ( deep_type);
+ DEBUG_A("base_type = ");
+ DEBUG_F(flexible_print, stderr, base_type, 1, (dump_flags_t)0);
- bool a_deep_reorg = is_reorg_type ( base_type_of ( deep_type), info);
+ bool a_deep_reorg = is_reorg_type ( base_type, info);
+ // TBD Test for modified too!
+ #if 1
+ bool modified = find_modified ( base_type, false, info);
+ if ( a_deep_reorg || modified || !lie )
+ {
+ return recognize_op_ret_action ( ReorgOpT_Indirect);
+ }
+ #else
if ( a_deep_reorg || !lie )
{
return recognize_op_ret_action ( ReorgOpT_Indirect);
}
+ #endif
// Just normal field reference otherwise...
return recognize_op_ret_action ( ReorgOpT_Scalar);
}
if ( tree_contains_a_reorgtype_p ( op, info))
{
- DEBUG_A("POINTER_TYPE_P ( type) : %s\n",
- POINTER_TYPE_P ( type) ? "true" : "false");
+ DEBUG_LA ( "POINTER_TYPE_P ( type) : %s\n",
+ POINTER_TYPE_P ( type) ? "true" : "false");
if ( POINTER_TYPE_P ( type))
{
- DEBUG_A("TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE : %s\n",
- TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE ? "true" : "false");
+ DEBUG_A ( "TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE : %s\n",
+ TREE_CODE ( TREE_TYPE( type)) == RECORD_TYPE ? "true" : "false");
}
}
if ( tree_contains_a_reorgtype_p ( op, info)
@@ -3207,7 +3401,7 @@ recognize_op ( tree op, bool lie, Info *info)
}
if ( inner_op0_code == INDIRECT_REF )
{
- DEBUG_L("TREE_CODE( inner_op) == INDIRECT_REF\n");
+ DEBUG_LA("TREE_CODE( inner_op) == INDIRECT_REF\n");
bool a_base_reorg = is_reorg_type ( base_type_of ( type), info);
if ( a_base_reorg || !lie )
{
@@ -3217,7 +3411,7 @@ recognize_op ( tree op, bool lie, Info *info)
return recognize_op_ret_action ( ReorgOpT_Scalar);
}
if ( inner_op0_code == MEM_REF ) {
- DEBUG_L("TREE_CODE( inner_op) == MEM_REF\n");
+ DEBUG_LA ( "TREE_CODE( inner_op) == MEM_REF\n");
bool a_reorg = is_reorg_type ( base_type_of ( inner_op0_type), info);
if ( a_reorg || !lie )
{
@@ -3228,14 +3422,14 @@ recognize_op ( tree op, bool lie, Info *info)
}
if ( inner_op0_code == COMPONENT_REF )
{
- DEBUG_L("TREE_CODE( inner_op) == COMPONENT_REF\n");
+ DEBUG_LA ( "TREE_CODE( inner_op) == COMPONENT_REF\n");
tree inner_op0_0 = TREE_OPERAND ( inner_op0, 0);
tree inner_op0_0_type = TREE_TYPE ( inner_op0_0);
- DEBUG_L("inner_op0_0 = ");
- DEBUG_F(flexible_print, stderr, inner_op0_0, 0, (dump_flags_t)0);
- DEBUG(" type = ");
- DEBUG_F(flexible_print, stderr, inner_op0_0_type, 0, (dump_flags_t)0);
- DEBUG(", TREE_CODE = %s\n", code_str( inner_op0_code));
+ DEBUG_A ( "inner_op0_0 = ");
+ DEBUG_F ( flexible_print, stderr, inner_op0_0, 0, (dump_flags_t)0);
+ DEBUG ( " type = ");
+ DEBUG_F ( flexible_print, stderr, inner_op0_0_type, 0, (dump_flags_t)0);
+ DEBUG ( ", TREE_CODE = %s\n", code_str( inner_op0_code));
bool a_reorg = is_reorg_type ( base_type_of ( inner_op0_0_type), info);
if ( a_reorg || !lie )
@@ -3245,7 +3439,7 @@ recognize_op ( tree op, bool lie, Info *info)
// Just normal field reference otherwise...
return recognize_op_ret_action ( ReorgOpT_Scalar);
}
- DEBUG_L("TREE_CODE( inner_op) not indirect, component or mem ref\n");
+ DEBUG_LA ( "TREE_CODE( inner_op) not indirect, component or mem ref\n");
// Note, doesn't this ignore ARRAY_REF of this?
// I think it's OK at least until we start supporting
// multi-pools.
@@ -3261,20 +3455,20 @@ recognize_op ( tree op, bool lie, Info *info)
}
case ARRAY_REF:
{
- //DEBUG_L("process: ARRAY_REF\n");
+ DEBUG_LA ( "process... ARRAY_REF\n");
tree inner_op1 = TREE_OPERAND( op, 1);
tree inner_op1_type = TREE_TYPE ( inner_op1);
- //DEBUG_A("inner_op0, inner_op0_type = ");
- //DEBUG_F(flexible_print, stderr, inner_op0, 2, (dump_flags_t)0);
- //DEBUG_F(flexible_print, stderr, inner_op0_type, 1, (dump_flags_t)0);
+ DEBUG_A ( "inner_op0, inner_op0_type = ");
+ DEBUG_F ( flexible_print, stderr, inner_op0, 2, (dump_flags_t)0);
+ DEBUG_F ( flexible_print, stderr, inner_op0_type, 1, (dump_flags_t)0);
- //DEBUG_A("inner_op1, inner_op1_type = ");
- //DEBUG_F(flexible_print, stderr, inner_op1, 2, (dump_flags_t)0);
- //DEBUG_F(flexible_print, stderr, inner_op1_type, 1, (dump_flags_t)0);
+ DEBUG_A ( "inner_op1, inner_op1_type = ");
+ DEBUG_F ( flexible_print, stderr, inner_op1, 2, (dump_flags_t)0);
+ DEBUG_F ( flexible_print, stderr, inner_op1_type, 1, (dump_flags_t)0);
if ( tree deep_type = multilevel_component_ref ( op) )
{
- //DEBUG_L("Is multilevel component ref (with array)\n");
+ DEBUG_LA ( "Is multilevel component ref (with array)\n");
bool a_reorg = is_reorg_type ( base_type_of ( deep_type), info);
if ( a_reorg || !lie )
{
@@ -3293,7 +3487,7 @@ recognize_op ( tree op, bool lie, Info *info)
}
case INDIRECT_REF:
{
- //DEBUG_L("process: INDIRECT_REF\n");
+ DEBUG_LA ( "process... INDIRECT_REF\n");
// Do we want to chase the base type?
// No, we care about (and transform) just
// *r and not **...r (where r is a ReorgType.)
@@ -3306,10 +3500,10 @@ recognize_op ( tree op, bool lie, Info *info)
}
case MEM_REF:
{
- //DEBUG_L("process: MEF_REF\n");
- //DEBUG_A("inner_op0, inner_op0_type = ");
- //DEBUG_F( flexible_print, stderr, inner_op0, 0, TDF_DETAILS);
- //DEBUG_F( flexible_print, stderr, inner_op0_type, 1, TDF_DETAILS);
+ DEBUG_LA ( "process... MEF_REF\n");
+ DEBUG_A ( "inner_op0, inner_op0_type = ");
+ DEBUG_F ( flexible_print, stderr, inner_op0, 0, TDF_DETAILS);
+ DEBUG_F ( flexible_print, stderr, inner_op0_type, 1, TDF_DETAILS);
bool a_reorg = is_reorg_type ( type, info);
if( a_reorg || !lie )
{
@@ -3327,13 +3521,13 @@ recognize_op ( tree op, bool lie, Info *info)
tree
multilevel_component_ref ( tree op)
{
- DEBUG_A("multilevel_component_ref: ");
- DEBUG_F(flexible_print, stderr, op, 1, (dump_flags_t)0);
- INDENT(2);
+ //DEBUG_A("multilevel_component_ref:> ");
+ //DEBUG_F(flexible_print, stderr, op, 1, (dump_flags_t)0);
+ //INDENT(2);
tree inner_op0 = TREE_OPERAND( op, 0);
//tree inner_op1 = TREE_OPERAND( op, 1);
enum tree_code inner_op0_code = TREE_CODE ( inner_op0);
- DEBUG_A("inner_op0_code = %s\n", code_str ( inner_op0_code ));
+ //DEBUG_A("inner_op0_code = %s\n", code_str ( inner_op0_code ));
if ( inner_op0_code == COMPONENT_REF || inner_op0_code == ARRAY_REF )
{
tree ret = multilevel_component_ref ( inner_op0);
@@ -3346,14 +3540,14 @@ multilevel_component_ref ( tree op)
if ( TREE_CODE ( op) == COMPONENT_REF )
{
tree type = TREE_TYPE (inner_op0);
- DEBUG_A(" found: %s, type: \n", code_str (inner_op0_code));
- DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
- INDENT(-2);
+ //DEBUG_A(" found: %s, type: \n", code_str (inner_op0_code));
+ //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
+ //INDENT(-2);
return type;
}
}
- DEBUG_A(" found: no deep type\n");
- INDENT(-2);
+ //DEBUG_A(" found: no deep type\n");
+ //INDENT(-2);
return NULL;
}
@@ -3368,21 +3562,25 @@ is_reorg_type( tree rt, Info *info )
tree
base_type_of ( tree type)
{
- //DEBUG_L("base_type_of: ");
- //DEBUG_F( print_generic_expr, stderr, type, TDF_DETAILS);
- //DEBUG("\n");
+ //DEBUG_A("base_type_of:> ");
+ //DEBUG_F( flexible_print, stderr, type, 1, (dump_flags_t)0);
+
for ( ; POINTER_TYPE_P ( type) ||
TREE_CODE ( type) == ARRAY_TYPE ||
TREE_CODE ( type) == VAR_DECL ||
TREE_CODE ( type) == PARM_DECL
; type = TREE_TYPE ( type) );
+
+ //DEBUG_A(" returns... ");
+ //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0);
+
return type;
}
tree
base_type_with_levels ( tree type, int *levels)
{
- //DEBUG_L("base_type_of: ");
+ //DEBUG_L("base_type_of:> ");
//DEBUG_F( print_generic_expr, stderr, type, TDF_DETAILS);
//DEBUG("\n");
int lev = 0;
@@ -3414,7 +3612,7 @@ is_reorg_alloc_trigger ( gimple *stmt)
static ReorgType_t *
find_struct_type_ptr_to_struct ( tree type, Info *info)
{
- //DEBUG_L( "find_struct_type_ptr_to_struct: ");
+ //DEBUG_L( "find_struct_type_ptr_to_struct:> ");
if ( !POINTER_TYPE_P ( type) ) {
//DEBUG(" bail\n");
@@ -3478,12 +3676,13 @@ apply_to_all_gimple ( bool (*function)(gimple *, void *), bool phis_too, void *d
bool
same_type_p ( tree a, tree b )
{
- //DEBUG( "same_type_p:\n");
- //DEBUG( " a: TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(a)),TYPE_NAME(a));
- //DEBUG_F( print_generic_expr, stderr, a, (dump_flags_t)-1);
- //DEBUG( "\n b TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(b)),TYPE_NAME(b));
- //DEBUG_F( print_generic_expr, stderr, b, (dump_flags_t)-1);
- //DEBUG( "\n");
+ //DEBUG_A( "same_type_p:>\n");
+ //DEBUG_A( " a: TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(a)),TYPE_NAME(a));
+ //DEBUG_A( " ");
+ //DEBUG_F( flexible_print, stderr, a, 1, (dump_flags_t)0);
+ //DEBUG_A( " b TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(b)),TYPE_NAME(b));
+ //DEBUG_A( " ");
+ //DEBUG_F( flexible_print, stderr, b, 1, (dump_flags_t)0);
// This replaces part of the below
bool a_rec = TREE_CODE ( a ) == RECORD_TYPE;
@@ -3499,12 +3698,13 @@ same_type_p ( tree a, tree b )
// Isn't that grand!
if ( TYPE_NAME ( a) == 0 || TYPE_NAME ( b) == 0 )
{
+ //DEBUG_A( "returns %s\n", a == b ? "true" : "false");
return a == b;
}
bool ret = TYPE_NAME ( a) == TYPE_NAME ( b);
- //DEBUG( "returns %s\n", ret ? "true" : "false");
+ //DEBUG_A( "returns %s\n", ret ? "true" : "false");
return ret;
}
@@ -3515,8 +3715,9 @@ same_type_p ( tree a, tree b )
ReorgType_t *
get_reorgtype_info ( tree type, Info* info)
{
- //DEBUG_L( "get_reorgtype_info: type = ");
+ //DEBUG_A ( "get_reorgtype_info:> type = ");
//DEBUG_F( flexible_print, stderr, type, 1, (dump_flags_t)0);
+ //
// Note, I'm going to use the most stupid and slowest possible way
// to do this. The advanage is it will be super easy and almost
@@ -3577,7 +3778,7 @@ detect_reorg ( tree *tp, int *dummy, void *data)
ReorgType_t *
contains_a_reorgtype ( gimple *stmt, Info *info)
{
- //DEBUG_L ( "contains_a_reorgtype: ");
+ //DEBUG_L ( "contains_a_reorgtype:> ");
//DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
//INDENT(2);
@@ -3676,6 +3877,11 @@ print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detai
// TBD
// note if reorg_perf & regular_perf are nonzero
// synthesize and display absolute_effect & raw_effect
+ if ( reorg == NULL )
+ {
+ fprintf ( file, "%*s(nil)\n", leading_space, "");
+ return;
+ }
// Note, the following is a stub.
if ( reorg->gcc_type != NULL && TYPE_NAME ( reorg->gcc_type) != NULL )
@@ -3813,7 +4019,7 @@ print_progdecl ( FILE *file, int leading_space, ProgDecl_t *progdecl )
}
void
-print_program ( FILE *file, bool my_format, int leading_space, Info_t *info)
+print_program ( FILE *file, bool my_format, bool internal, int leading_space, Info_t *info)
{
struct cgraph_node *node;
fprintf ( file, "%*sProgram:\n", leading_space, "");
@@ -3835,7 +4041,7 @@ print_program ( FILE *file, bool my_format, int leading_space, Info_t *info)
if ( my_format )
{
flexible_print ( file, TREE_TYPE( func->decl), 1, (dump_flags_t)0);
- print_function ( file, leading_space + 4, func);
+ print_function ( file, internal, leading_space + 4, func, info);
}
else
{
@@ -3845,12 +4051,16 @@ print_program ( FILE *file, bool my_format, int leading_space, Info_t *info)
}
}
- DEBUG ("INTERNALS PRINT:\n");
- DEBUG_F (apply_to_all_gimple, print_internals, true, (void*)info);
+ //DEBUG ("INTERNALS PRINT:\n");
+ //DEBUG_F (apply_to_all_gimple, print_internals, true, (void*)info);
}
static void
-print_function ( FILE *file, int leading_space, struct function *func)
+print_function ( FILE *file,
+ bool internals,
+ int leading_space,
+ struct function *func,
+ Info *info)
{
basic_block bb;
@@ -3914,7 +4124,14 @@ print_function ( FILE *file, int leading_space, struct function *func)
for ( phii = gsi_start (seq); !gsi_end_p (phii); gsi_next (&phii))
{
fprintf ( file, "%*s", leading_space + 6, "" );
- print_gimple_stmt ( file, gsi_stmt ( phii), 0, TDF_DETAILS);
+ if ( internals )
+ {
+ print_internals ( gsi_stmt ( phii), (void*) info);
+ }
+ else
+ {
+ print_gimple_stmt ( file, gsi_stmt ( phii), 0, TDF_DETAILS);
+ }
}
}
@@ -3926,7 +4143,14 @@ print_function ( FILE *file, int leading_space, struct function *func)
gimple *stmt = gsi_stmt ( gsi);
fprintf ( file, "%*s", leading_space + 6, "" );
// Issue: for "if" this does not print the gotos.
- print_gimple_stmt ( file, stmt, 0, TDF_DETAILS);
+ if ( internals )
+ {
+ print_internals ( stmt, (void*) info);
+ }
+ else
+ {
+ print_gimple_stmt ( file, stmt, 0, TDF_DETAILS);
+ }
}
}
}
@@ -3934,7 +4158,7 @@ print_function ( FILE *file, int leading_space, struct function *func)
ReorgType_t *
get_reorgtype( gimple *stmt, Info *info, int i)
{
- //DEBUG_A("get_reorgtype: i = %d, stmt = ", i);
+ //DEBUG_A("get_reorgtype:> i = %d, stmt = ", i);
//DEBUG_F(print_gimple_stmt, stderr, stmt, 0);
// Looking at operands of statement, when we get to
// the ith one, return it.
@@ -3984,7 +4208,7 @@ get_reorgtype( gimple *stmt, Info *info, int i)
int
num_reorgtypes( gimple *stmt, Info *info)
{
- //DEBUG_L("num_reorgtypes: ");
+ //DEBUG_LA("num_reorgtypes:> ");
//DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
// Looking at operands of statement, count
// the number that have reorg types.
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index 20d81abb035..c421f32cfee 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -32,7 +32,14 @@ along with GCC; see the file COPYING3. If not see
#define BYPASS_TRANSFORM false
// Use Erick's escape analysis
#define USE_ESCAPE_ANALYSIS 1
+// Enables old code sequence (this breaks things)
#define USE_DO_INSTANCE_INTERLEAVE 0
+// Testing reversing the sense of modification comparison.
+// This is because the decl types are modified before
+// compoment reference expressions are modified so to
+// detect something needing modification we need to the
+// determine the decl was modified.
+#define ALLOW_REVERSE 1
typedef struct RT_Elim RT_Elim;
typedef struct RT_Reorder RT_Reorder;
@@ -254,10 +261,25 @@ extern int str_reorg_instance_interleave ( Info *);
#endif
extern void find_and_create_all_modified_types ( Info_t *);
extern std::vector<two_trees_t>::iterator find_in_vec_of_two_types ( std::vector<two_trees_t> *, tree);
-extern tree find_modified ( tree, Info_t *);
+extern std::vector<two_trees_t>::iterator find_in_vec_of_two_types_2nd ( std::vector<two_trees_t> *, tree);
+extern tree find_modified ( tree,
+ #if ALLOW_REVERSE
+ bool,
+ #endif
+ Info_t *);
+extern tree find_deepest_comp_ref_type ( tree);
extern bool new_contains_a_modified ( gimple *, tree *, tree *, Info_t *);
-extern tree contains_a_modified ( gimple *, Info_t *);
+extern tree contains_a_modified ( gimple *,
+ #if ALLOW_REVERSE
+ bool,
+ #endif
+ Info_t *);
extern tree find_deepest_comp_ref ( tree);
+#if 0
+extern void modify_local_declarations ( Info *);
+#endif
+extern void modify_global_declarations ( Info *);
+extern void modify_parameter_declarations ( Info *);
extern int number_of_levels ( tree);
extern tree make_multilevel( tree, int);
extern bool modify_decl_core ( tree *, Info *);
@@ -265,7 +287,7 @@ extern void delete_reorgtype ( ReorgType_t *, Info_t *);
extern void undelete_reorgtype ( ReorgType_t *, Info_t *);
extern void clear_deleted_types( Info *);
extern void restore_deleted_types ( Info *);
-extern void remove_deleted_types ( Info *, ReorgFn);
+extern void remove_deleted_types ( Info *, char *, ReorgFn);
extern enum ReorgOpTrans recognize_op ( tree, bool, Info_t *);
extern ReorgTransformation reorg_recognize ( gimple *,
cgraph_node *,
@@ -282,7 +304,7 @@ extern bool is_reorg_type ( tree, Info_t *);
extern tree base_type_of ( tree);
extern tree base_type_with_levels ( tree, int *);
extern void print_reorg ( FILE *, int, ReorgType_t *);
-extern void print_program ( FILE *, bool, int, Info_t *);
+extern void print_program ( FILE *, bool, bool, int, Info_t *);
extern void print_type ( FILE *, tree);
extern void modify_ssa_name_type ( tree, tree);
extern bool print_internals (gimple *, void *);
@@ -294,8 +316,7 @@ extern bool is_assign_from_ssa ( gimple *);
// I have no intention of leaving these debugging marcos or uses of
// them in the code. However, some of the uses should obviously be
-// converted to dump file information.
-
+// converted to dump file information.0
#define DEBUGGING 0
#if DEBUGGING
enum Display {
@@ -316,6 +337,10 @@ extern const char *code_str( enum tree_code);
extern void wolf_fence( Info *);
extern bool ssa_check ( FILE *, Display, Failure, bool, bool);
+// File and line numbered followed by DEBUG_A on next line
+#define DEBUG_FLA(...) { fprintf( stderr, "L# %s:%4d: \n%*s", __FILE__, __LINE__, debug_indenting + 7, ""); fprintf( stderr, __VA_ARGS__); }
+// Line numbered followed by DEBUG_A on next line
+#define DEBUG_LA(...) { fprintf( stderr, "L# %4d: \n%*s", __LINE__, debug_indenting + 7, ""); fprintf( stderr, __VA_ARGS__); }
// Line numbered
#define DEBUG_L(...) { fprintf( stderr, "L# %4d: %*s", __LINE__, debug_indenting, ""); fprintf( stderr, __VA_ARGS__); }
// Alinged with line numbered
@@ -325,6 +350,8 @@ extern bool ssa_check ( FILE *, Display, Failure, bool, bool);
#define DEBUG_F(f,...) f( __VA_ARGS__)
#define INDENT(a) handle_debug_indenting(a)
#else
+#define DEBUG_FLA(...)
+#define DEBUG_LA(...)
#define DEBUG_L(...)
#define DEBUG_A(...)
#define DEBUG(...)
diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c
index f05ffc1a5ef..eb19d5c41ca 100644
--- a/gcc/ipa-type-escape-analysis.c
+++ b/gcc/ipa-type-escape-analysis.c
@@ -286,7 +286,11 @@ get_whitelisted_nodes()
if (detected_incompatible_syntax) return map;
cgraph_node *i = worklist.front();
worklist.pop();
+ #if 0
if (dump_file) fprintf(dump_file, "analyzing %s %p\n", i->name(), i);
+ #else
+ if (dump_file) fprintf(dump_file, "analyzing %s\n", i->name());
+ #endif
GimpleWhiteLister whitelister;
whitelister._walk_cnode(i);
bool no_external = whitelister.does_not_call_external_functions(i, map);