diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-12-12 12:06:10 -0800 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-12-12 12:06:10 -0800 |
commit | 4d3c3f539052c89a6b41b67f801417c2a8e0b522 (patch) | |
tree | b36e7947991f752d01fcad6f457adf74da179d03 | |
parent | 7efbaae0d7e2b3af6c403fc81d4ffd379fa18c59 (diff) |
Need to save things in stable but still slightly broken state
before I make some major changes.
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 191 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.c | 221 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.h | 2 | ||||
-rw-r--r-- | gcc/ipa-type-escape-analysis.h | 2 |
4 files changed, 298 insertions, 118 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index 958a4b1b54e..60c8436c169 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -19,6 +19,9 @@ 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> @@ -62,6 +65,7 @@ static void wrangle_ssa_type( tree, Info_t*); static void str_reorg_instance_interleave_qual_part ( Info *); static void str_reorg_instance_interleave_type_part ( Info *); static void header ( bool); +static void reorg_perf_qual_debug ( Info *, ReorgType *); static void print_var_infos ( FILE *, std::vector<varInfo_t> &); static void compress_acc_infos ( std::vector <acc_info_t>); static void print_acc_info ( FILE *, acc_info_t *); @@ -198,13 +202,11 @@ str_reorg_instance_interleave_trans ( Info *info) ReorgType_t *ri = contains_a_reorgtype( stmt, info); if ( ri == NULL ) { - //DEBUG_L("No Transfrom on: "); - //DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM); - // NEW STUFF // Find assigns that are basically element assigns. // 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); if ( modified ) { @@ -227,6 +229,17 @@ str_reorg_instance_interleave_trans ( Info *info) } else { + #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_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"); @@ -399,7 +412,7 @@ str_reorg_instance_interleave_trans ( Info *info) element_assign_transformation (stmt, ri, info); #endif - //INDENT(-2); + INDENT(-2); } // end ReorgT_ElemAssign case break; case ReorgT_If_Null: @@ -2261,7 +2274,7 @@ str_reorg_instance_interleave_trans ( Info *info) } } } - //INDENT(-4); + INDENT(-4); // Normal ssa name case DEBUG_L("Dangling Types for Normal SSA Names:\n"); @@ -2597,13 +2610,24 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info) { gimple_stmt_iterator gsi = gsi_for_stmt( stmt); - DEBUG_L("new_element_assign_transformation: "); + DEBUG_A("new_element_assign_transformation: "); DEBUG_F( print_gimple_stmt, stderr, stmt, 0); + INDENT(2); + + #if GATE1 tree modif_type = contains_a_modified ( stmt, info); - DEBUG_A("Modification for = "); - DEBUG_F(flexible_print, stderr, modif_type, 1, (dump_flags_t)0); + #else + tree lhs_mod; + tree rhs_mod; + bool has_modification = + new_contains_a_modified ( stmt, &lhs_mod, &rhs_mod, info ); + + DEBUG_A("lhs_mod = "); + 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 - INDENT(2); // Needed for helloworld tree lhs = gimple_assign_lhs( stmt); tree rhs = gimple_assign_rhs1( stmt); @@ -2627,8 +2651,14 @@ new_element_assign_transformation ( gimple *stmt, ReorgType_t *ri, Info_t *info) tree ref_expr; 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; @@ -2860,12 +2890,16 @@ new_make_transformed_ref ( tree ref_in, { DEBUG_A("new_make_transformed_ref:\n"); INDENT(2); + tree gcc_type = ri->gcc_type; + 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; @@ -2879,6 +2913,8 @@ 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); @@ -2907,8 +2943,24 @@ new_make_transformed_ref ( tree 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: @@ -2939,6 +2991,9 @@ new_make_transformed_ref ( tree ref_in, 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 @@ -2976,60 +3031,78 @@ new_make_transformed_ref ( tree ref_in, } +// This is oddly close to multilevel_component_ref 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))); - #if 1 + 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); return NULL; } - #else - if ( TREE_CODE(comp_ref_expr) == SSA_NAME ) return NULL; - #endif + 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) ); if ( inner_op0_code == COMPONENT_REF ) { - return find_deepest_comp_ref ( inner_op0); + tree ret = find_deepest_comp_ref ( inner_op0); + INDENT(-2); + return ret; } - else if ( inner_op0_code == MEM_REF ) + else if ( inner_op0_code == MEM_REF || inner_op0_code == VAR_DECL ) { + DEBUG_A("bottom\n"); + INDENT(-2); return comp_ref_expr; } + DEBUG_A("fell through returns NULL\n"); + INDENT(-2); return NULL; } static tree -create_deep_ref ( tree old_ref, tree field_type, tree field_addr ) +create_deep_ref ( tree ref_in, tree field_type, tree field_addr ) { - //DEBUG_A("create_deep_ref: "); - //DEBUG_F(flexible_print, stderr, old_ref, 1, (dump_flags_t)0); - //INDENT(4); - tree inner_op0 = TREE_OPERAND( old_ref, 0); + DEBUG_A("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); + DEBUG_A("TREE_CODE ( ref_in) = %s\n", code_str( top_code)); + tree inner_op0 = TREE_OPERAND( ref_in, 0); enum tree_code inner_op0_code = TREE_CODE ( inner_op0); - enum tree_code top_code = TREE_CODE ( old_ref); if ( inner_op0_code == MEM_REF ) { + DEBUG_A("MEM_REF\n"); tree deepest = build2 ( MEM_REF, field_type, field_addr, build_int_cst (ptr_type_node, 0)); - //INDENT(-4); - //DEBUG_A("returns deepest: "); - //DEBUG_F(flexible_print, stderr, deepest, 1, (dump_flags_t)0); + DEBUG_A("returns deepest: "); + DEBUG_F(flexible_print, stderr, deepest, 1, (dump_flags_t)0); + INDENT(-4); return deepest; } + else if ( inner_op0_code == VAR_DECL ) + { + // In this situation we are seeing var.field + // but that is not something to be transformed. + gcc_assert (0); + } else if ( top_code == COMPONENT_REF ) { + DEBUG_A("COMPONENT_REF\n"); tree lower_comp_part = create_deep_ref ( inner_op0, field_type, field_addr); - tree level_field = TREE_OPERAND( old_ref, 1);; + tree level_field = TREE_OPERAND( ref_in, 1);; tree level_field_type = TREE_TYPE ( level_field); tree component_layer = build3 ( COMPONENT_REF, @@ -3038,19 +3111,20 @@ create_deep_ref ( tree old_ref, tree field_type, tree field_addr ) level_field, NULL_TREE); - //INDENT(-4); - //DEBUG_A("returns component_layer: "); - //DEBUG_F(flexible_print, stderr, component_layer, 1, (dump_flags_t)0); + DEBUG_A("returns component_layer: "); + DEBUG_F(flexible_print, stderr, component_layer, 1, (dump_flags_t)0); + INDENT(-4); return component_layer; } else if ( top_code == ARRAY_REF ) { + DEBUG_A("ARRAY_REF\n"); tree lower_array_part = create_deep_ref ( inner_op0, field_type, field_addr); - tree array_index = TREE_OPERAND( old_ref, 1); - tree elem_type = TREE_TYPE ( old_ref); + tree array_index = TREE_OPERAND( ref_in, 1); + tree elem_type = TREE_TYPE ( ref_in); tree array_layer = build4 ( ARRAY_REF, @@ -3059,9 +3133,9 @@ create_deep_ref ( tree old_ref, tree field_type, tree field_addr ) array_index, NULL_TREE, NULL_TREE); - //INDENT(-4); - //DEBUG_A("returns array_layer: "); - //DEBUG_F(flexible_print, stderr, array_layer, 1, (dump_flags_t)0); + DEBUG_A("returns array_layer: "); + DEBUG_F(flexible_print, stderr, array_layer, 1, (dump_flags_t)0); + INDENT(-4); return array_layer; } @@ -3334,7 +3408,7 @@ reorg_perf_qual ( Info *info) fprintf ( info->reorg_dump_file, "Doing Performance Qualification\n"); } DEBUG_L("reorg_perf_qual:\n"); - #if 1 + #if USE_DO_INSTANCE_INTERLEAVE // TBD use design in doc but mark ReorgTypes // (do_instance_interleave) that qualify instead of deleting them // unless both dead field elimination and field reorderig are not @@ -3432,7 +3506,11 @@ reorg_perf_qual ( Info *info) INDENT(4); if ( gimple_code ( stmt) == GIMPLE_LABEL || - gimple_code ( stmt) == GIMPLE_SWITCH ) continue; + gimple_code ( stmt) == GIMPLE_SWITCH ) + { + INDENT(-4); + continue; + } unsigned n_ops = gimple_num_ops( stmt); tree op; @@ -3860,7 +3938,11 @@ reorg_perf_qual ( Info *info) (dump_flags_t)0); fprintf ( info->reorg_dump_file, ": Doesn't occur in any meaningful loop.\n"); } + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = false; + #else + delete_reorgtype ( &(*reorgi), info); + #endif continue; } @@ -3890,7 +3972,11 @@ reorg_perf_qual ( Info *info) " raw_effect %5.4f < SINGLE_POOL_RAW_SKIP_IT %5.4f\n", raw_effect, SINGLE_POOL_RAW_SKIP_IT); } + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = false; + #else + delete_reorgtype ( &(*reorgi), info); + #endif continue; } // the relative effect is big enough do it anyway @@ -3908,8 +3994,9 @@ reorg_perf_qual ( Info *info) " raw_effect %5.4f >= SINGLE_POOL_RAW_DO_IT_ALWAYS %5.4f\n", raw_effect, SINGLE_POOL_RAW_DO_IT_ALWAYS); } - + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = true; + #endif continue; } if ( absolute_effect < SINGLE_POOL_ABS_SKIP_IT ) @@ -3926,7 +4013,11 @@ reorg_perf_qual ( Info *info) absolute_effect, SINGLE_POOL_ABS_SKIP_IT); } + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = false; + #else + delete_reorgtype ( &(*reorgi), info); + #endif continue; } if ( absolute_effect >= SINGLE_POOL_ABS_DO_IT_ALWAYS ) @@ -3942,8 +4033,10 @@ reorg_perf_qual ( Info *info) " absolute_effect %5.4f >= SINGLE_POOL_ABS_DO_IT_ALWAYS %5.4f\n", absolute_effect, SINGLE_POOL_ABS_DO_IT_ALWAYS); } - + + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = true; + #endif continue; } @@ -3965,7 +4058,11 @@ reorg_perf_qual ( Info *info) raw_effect, cut_off); } + #if USE_DO_INSTANCE_INTERLEAVE reorgi->do_instance_interleave = false; + #else + delete_reorgtype ( &(*reorgi), info); + #endif continue; } @@ -3981,10 +4078,25 @@ reorg_perf_qual ( Info *info) } } + + #if USE_DO_INSTANCE_INTERLEAVE + remove_deleted_types ( info, reorg_perf_qual_debug); + #endif + #endif } static void +reorg_perf_qual_debug ( Info *info, ReorgType *reorg ) +{ + if ( info->show_delete ) + { + print_reorg_with_msg ( info->reorg_dump_file, reorg, 2, + "Was not allocated"); + } +} + +static void print_var_info ( FILE *file, varInfo_t &vinfo) { print_acc_info ( file, vinfo.rep_access ); @@ -4262,7 +4374,7 @@ account_for_access ( tree access, tree field, std::vector <acc_info_t> *acc_info static void tmasn_helper ( tree t, int indent, std::set<tree> *already ) { - //DEBUG_A(""); + DEBUG_A(""); fprintf( stderr, "%*s", indent, " "); indent += 4; flexible_print ( stderr, t, 0, (dump_flags_t)0); @@ -4337,6 +4449,7 @@ tmasn_helper ( tree t, int indent, std::set<tree> *already ) return; } if ( TREE_CODE ( t) == INTEGER_CST ) return; + if ( TREE_CODE ( t) == ADDR_EXPR ) return; fprintf ( stderr, "unanticipated TREE_CODE\n"); gcc_assert ( 0); } diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 5fbdd2e5d4b..ba496ad6578 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -609,8 +609,13 @@ find_decls_and_types ( Info *info) != escaping_nonescaping_sets.non_escaping.end ()) { + // Ignore non records + //if ( TREE_CODE ( type) != RECORD_TYPE ) continue; + 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); if ( TYPE_FIELDS ( canonical) == NULL ) continue; // The types here are highly redundant so ignore @@ -1657,6 +1662,54 @@ find_modified ( tree type, Info_t *info ) return resulti->second; } +bool +new_contains_a_modified ( gimple *stmt, tree *lhs_mod, tree *rhs_mod, Info_t *info ) +{ + bool modified = false; + *lhs_mod = NULL; + *rhs_mod = NULL; + DEBUG_A("new_contains_a_modified: "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + INDENT(2); + // For an assign check both sides component refs. + if ( gimple_code ( stmt) == GIMPLE_ASSIGN ) + { + tree lhs = gimple_assign_lhs( stmt); + tree rhs = NULL; + gassign *gass = static_cast <gassign *> (stmt); + // A simple + if ( get_gimple_rhs_class ((enum tree_code)gass->subcode) + == + GIMPLE_SINGLE_RHS) + { + rhs = gimple_assign_rhs1 ( stmt); + } + // Use find_deepest_comp_ref on both sides. It's safe in + // meaningless circumstances. + tree l_deepest_type = find_deepest_comp_ref_type ( lhs); + tree r_deepest_type; + //If a side has a deepest component ref check to see if + // modified. + if ( l_deepest_type ) + { + if ( find_modified ( l_deepest_type, info) ) + { + *lhs_mod = l_deepest_type; + modified = true; + } + } + if ( rhs + && (r_deepest_type = find_deepest_comp_ref_type ( rhs)) + && find_modified ( r_deepest_type, info) ) + { + *rhs_mod = r_deepest_type; + modified = true; + } + } + INDENT(-2); + return modified; +} + tree contains_a_modified ( gimple *stmt, Info_t *info ) { @@ -2587,28 +2640,28 @@ 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_F ( print_gimple_stmt, stderr, stmt, 0); - //INDENT(2); + DEBUG_L ( "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_L("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"); - //INDENT(2); + DEBUG_L("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"); - //INDENT(-4); + DEBUG_L("case ReorgOpT_Pointer\n"); + INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Scalar: @@ -2642,8 +2695,8 @@ 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"); - //INDENT(-4); + DEBUG_L("case ReorgOpT_Struct\n"); + INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Deref: // "*a" @@ -2659,8 +2712,8 @@ 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"); - //INDENT(-4); + DEBUG_L("case ReorgOpT_Deref\n"); + INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Deref: // "*a" @@ -2671,8 +2724,8 @@ 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"); - //INDENT(-4); + DEBUG_L("case ReorgOpT_Array\n"); + INDENT(-4); switch ( recognize_op ( rhs, true, info) ) { case ReorgOpT_Struct: // "s" @@ -2685,8 +2738,8 @@ 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"); - //INDENT(-4); + DEBUG_L("case ReorgOpT_%s\n", lhs_op == ReorgOpT_Temp ? "Temp" : "Scalar"); + INDENT(-4); switch ( recognize_op( rhs, true, info) ) { case ReorgOpT_Scalar: // "z" @@ -2739,24 +2792,24 @@ 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"); - //INDENT(2); + DEBUG_L("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(""); - //DEBUG_F( flexible_print, stderr, op1, 1, TDF_DETAILS); + DEBUG_L("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"); - //INDENT(-4); + DEBUG_L("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"); - //INDENT(-4); + DEBUG_L("gimple_assign_rhs3 ( stmt) != NULL\n"); + INDENT(-4); return REORG_RECOG_RET_ACT ( Not_Supported); } @@ -2766,8 +2819,8 @@ 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" ); - //INDENT(-4); + DEBUG_L("zero_case = %s\n", zero_case ? "true" : "false" ); + INDENT(-4); switch ( rhs_code ) { case POINTER_PLUS_EXPR: @@ -2793,8 +2846,8 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) } case GIMPLE_COND: // Similar to assign cases { - //DEBUG_L("GIMPLE_COND:\n"); - //INDENT(-2); + DEBUG_L("GIMPLE_COND:\n"); + INDENT(-2); //tree op1 = gimple_assign_rhs1 ( stmt); //tree op2 = gimple_assign_rhs2( stmt); tree op1 = gimple_cond_lhs ( stmt); @@ -2825,17 +2878,17 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) } case GIMPLE_CALL: { - //DEBUG_L("GIMPLE_CALL:\n"); + DEBUG_L("GIMPLE_CALL:\n"); struct cgraph_edge *edge = node->get_edge ( stmt); gcc_assert( edge); - //DEBUG_L("called function %s gimple_body\n", - // edge->callee->has_gimple_body_p() ? "has a" : "has no"); - //DEBUG_L("called function inline_to %s\n", - // edge->callee->inlined_to ? "true" : "false"); - //DEBUG_L("called function external %s\n", - // edge->callee->get_partitioning_class() == SYMBOL_EXTERNAL ? "true" : "false"); + DEBUG_L("called function %s gimple_body\n", + edge->callee->has_gimple_body_p() ? "has a" : "has no"); + DEBUG_L("called function inline_to %s\n", + edge->callee->inlined_to ? "true" : "false"); + DEBUG_L("called function external %s\n", + edge->callee->get_partitioning_class() == SYMBOL_EXTERNAL ? "true" : "false"); - //INDENT(-2); + INDENT(-2); if ( gimple_call_builtin_p( stmt, BUILT_IN_CALLOC ) ) return REORG_RECOG_RET_ACT ( ReorgT_Calloc); if ( gimple_call_builtin_p( stmt, BUILT_IN_MALLOC ) ) return REORG_RECOG_RET_ACT ( ReorgT_Malloc); if ( gimple_call_builtin_p( stmt, BUILT_IN_REALLOC) ) return REORG_RECOG_RET_ACT ( ReorgT_Realloc); @@ -2848,24 +2901,24 @@ reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) if ( is_user_function ( stmt, node, info) ) { - //DEBUG_A(" ReorgT_UserFunc\n"); + DEBUG_A(" ReorgT_UserFunc\n"); return REORG_RECOG_RET_ACT ( ReorgT_UserFunc); } - //DEBUG_A(" Not_supported\n"); + DEBUG_A(" Not_supported\n"); // TBD Why is this commented out? //return Not_Supported; } break; case GIMPLE_RETURN: - //DEBUG_L("GIMPLE_RETURN:\n"); - //INDENT(-2); + DEBUG_L("GIMPLE_RETURN:\n"); + INDENT(-2); return REORG_RECOG_RET_ACT ( ReorgT_Return); break; default: - //DEBUG_L ( "didn't support: "); - //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - //DEBUG( "\n"); - //INDENT(-2); + DEBUG_L ( "didn't support: "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + DEBUG( "\n"); + INDENT(-2); return REORG_RECOG_RET_ACT ( Not_Supported); } } @@ -2979,10 +3032,10 @@ recognize_op_ret_action ( enum ReorgOpTrans e ) enum ReorgOpTrans recognize_op ( tree op, bool lie, Info *info) { - //DEBUG_L("recognize_op: "); - //DEBUG_F( flexible_print, stderr, op, 1, TDF_DETAILS); + DEBUG_L("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)); + DEBUG_A("opcode = %s\n", code_str( op_code)); switch ( op_code ) { case INTEGER_CST: @@ -3112,20 +3165,20 @@ recognize_op ( tree op, bool lie, Info *info) } case COMPONENT_REF: { - //DEBUG_L("process: COMPONENT_REF\n"); + DEBUG_L("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_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)); // 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_L("Is multilevel component ref: deep_type is "); + DEBUG_F(flexible_print, stderr, deep_type, 1, (dump_flags_t)0); bool a_deep_reorg = is_reorg_type ( base_type_of ( deep_type), info); if ( a_deep_reorg || !lie ) @@ -3137,12 +3190,12 @@ recognize_op ( tree op, bool lie, Info *info) } if ( tree_contains_a_reorgtype_p ( op, info)) { - //DEBUG_A("POINTER_TYPE_P ( type) : %s\n", - // POINTER_TYPE_P ( type) ? "true" : "false"); + DEBUG_A("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) @@ -3154,7 +3207,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_L("TREE_CODE( inner_op) == INDIRECT_REF\n"); bool a_base_reorg = is_reorg_type ( base_type_of ( type), info); if ( a_base_reorg || !lie ) { @@ -3164,7 +3217,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_L("TREE_CODE( inner_op) == MEM_REF\n"); bool a_reorg = is_reorg_type ( base_type_of ( inner_op0_type), info); if ( a_reorg || !lie ) { @@ -3175,14 +3228,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_L("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_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)); bool a_reorg = is_reorg_type ( base_type_of ( inner_op0_0_type), info); if ( a_reorg || !lie ) @@ -3192,7 +3245,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_L("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. @@ -3269,35 +3322,38 @@ recognize_op ( tree op, bool lie, Info *info) } } + +// This is oddly close to find_deepest_comp_ref 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 )); if ( inner_op0_code == COMPONENT_REF || inner_op0_code == ARRAY_REF ) { tree ret = multilevel_component_ref ( inner_op0); - //INDENT(-2); + INDENT(-2); return ret; } else - if ( inner_op0_code == MEM_REF ) + if ( inner_op0_code == MEM_REF || inner_op0_code == VAR_DECL ) { 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; } @@ -3646,7 +3702,8 @@ print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detai // TBD fprintf ( file, "}, "); } - + + #if USE_DO_INSTANCE_INTERLEAVE if ( reorg->do_instance_interleave ) { fprintf ( file, "inter:{ "); @@ -3660,6 +3717,14 @@ print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detai { fprintf ( file, "no interleave, "); } + #else + fprintf ( file, "inter:{ "); + // TBD + fprintf ( file, "%s, ", + reorg->instance_interleave.multi_pool ? "multi" : "single" ); + // TBD When multi-pool implemented (and found) emit pointer_rep. + fprintf ( file, "}, "); + #endif //DEBUG_L("reorg->reorg_ver_type = %p\n", reorg->reorg_ver_type); diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index 6acc9f04f1b..20d81abb035 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #define BYPASS_TRANSFORM false // Use Erick's escape analysis #define USE_ESCAPE_ANALYSIS 1 +#define USE_DO_INSTANCE_INTERLEAVE 0 typedef struct RT_Elim RT_Elim; typedef struct RT_Reorder RT_Reorder; @@ -254,6 +255,7 @@ extern int str_reorg_instance_interleave ( Info *); 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 bool new_contains_a_modified ( gimple *, tree *, tree *, Info_t *); extern tree contains_a_modified ( gimple *, Info_t *); extern tree find_deepest_comp_ref ( tree); extern int number_of_levels ( tree); diff --git a/gcc/ipa-type-escape-analysis.h b/gcc/ipa-type-escape-analysis.h index 7f271cbc9f6..165ff116038 100644 --- a/gcc/ipa-type-escape-analysis.h +++ b/gcc/ipa-type-escape-analysis.h @@ -32,7 +32,7 @@ void log (const char *const fmt, ...) __attribute__((format(printf, 1, 0))); inline void log (const char *const fmt, ...) { - if (!dump_file) + //if (!dump_file) return; va_list args; |