From f53b7b076eb06975970e223ce37c308b3a4ad00c Mon Sep 17 00:00:00 2001 From: Gary Oblock Date: Thu, 24 Sep 2020 11:42:08 -0700 Subject: Added new case in code to count the number of dynamic allocations (pools) for a reorg type. --- gcc/ipa-str-reorg-instance-interleave.c | 20 ++++----- gcc/ipa-structure-reorg.c | 79 ++++++++++++++++++++++----------- gcc/ipa-structure-reorg.h | 2 +- 3 files changed, 62 insertions(+), 39 deletions(-) diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index d53d290f980..1d0213f1427 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -1913,6 +1913,7 @@ static bool is_array_access( tree); static unsigned int reorg_perf_qual ( Info *info) { + DEBUG_L("reorg_perf_qual:\n"); #if 1 // TBD use design in doc but mark ReorgTypes // (do_instance_interleave) that qualify instead of deleting them @@ -1926,17 +1927,6 @@ reorg_perf_qual ( Info *info) (*(info->reorg_type))[i].do_instance_interleave = true; } #else - - // This dom sequence is broken and I'm stalled on it. - // I used the sequence before but the upstream code (not - // my pass) is broken. - if ( dom_info_available_p ( CDI_DOMINATORS) ) - { - free_dominance_info ( CDI_DOMINATORS); - } - - calculate_dominance_info (CDI_DOMINATORS); - // We are doing a quick and dirty version of performance // qualification for testing purposes and possibly the // initial version of for the main branch. @@ -1962,7 +1952,15 @@ reorg_perf_qual ( Info *info) FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) { struct function *func = DECL_STRUCT_FUNCTION ( node->decl); // Ulgy GCC idiom with global pointer to current function. + // However, the dominace calculations other things need it. push_cfun ( func); + + if ( dom_info_available_p ( CDI_DOMINATORS) ) + { + free_dominance_info ( CDI_DOMINATORS); + } + calculate_dominance_info (CDI_DOMINATORS); + // TBD std::vector loop_perf; loop_perf.reserve ( number_of_loops ( func)); diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 7df8f5846d4..196b8cb393f 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -45,6 +45,8 @@ along with GCC; see the file COPYING3. If not see #include #include #include "ipa-structure-reorg.h" +#include "tree-phinodes.h" +#include "ssa-iterators.h" static void setup_debug_flags ( Info *); @@ -116,12 +118,6 @@ int debug_indenting = 0; static unsigned int ipa_structure_reorg ( void) { - // Here to test the sanity of the compiler (yes, it's insane.) - //if ( dom_info_available_p ( CDI_DOMINATORS) ) - // { - // free_dominance_info ( CDI_DOMINATORS); - // } - std::vector Reorg_Type; std::vector Saved_Reorg_Type; std::vector Prog_Decl; @@ -325,36 +321,62 @@ reorg_analysis ( Info *info) gsi_next ( &gsi) ) { gimple *stmt = gsi_stmt ( gsi); - //DEBUG_L ( ""); - //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - //INDENT(2); + DEBUG_L ( ""); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); + INDENT(2); if ( is_gimple_call ( stmt) ) { // next line has issues but the mechanism is sound tree t = *gimple_call_lhs_ptr ( stmt); - //DEBUG_A( "t %p\n", t); + DEBUG_A( "t %p\n", t); // Calls to a function returning void are skipped. if ( t != NULL ) { + DEBUG_A( "t: "); + DEBUG_F( flexible_print, stderr, t, 1, (dump_flags_t)0); tree type = TREE_TYPE( t); + DEBUG_A( "type: "); + DEBUG_F( flexible_print, stderr, type, 1, (dump_flags_t)0); //tree bt = base_type_of ( t); tree bt = base_type_of ( type); - if ( TREE_CODE( bt) != RECORD_TYPE ) + if ( TREE_CODE( bt) != RECORD_TYPE && TREE_CODE( bt) != VOID_TYPE) { - //DEBUG_A( "TREE_CODE( bt) == %s\n", code_str( TREE_CODE ( bt))); - //DEBUG_A(""); - //DEBUG_F( print_generic_expr, stderr, bt, (dump_flags_t)-1); - //INDENT(-2); + DEBUG_A( "TREE_CODE( bt) == %s\n", code_str( TREE_CODE ( bt))); + DEBUG_A(""); + DEBUG_F(flexible_print, stderr, bt, 1, (dump_flags_t)0); + INDENT(-2); continue; } + if ( TREE_CODE( bt) == VOID_TYPE ) + { + // find the use of lhs. If is an assign + // get use the base type of it's lhs. + // Otherwise never mind. + gimple *use_stmt; + use_operand_p immuse; + bool yup_a_use = single_imm_use ( t, &immuse, &use_stmt); + DEBUG_A("VOID case: %sa single imm use, ", yup_a_use ? "" : "not "); + DEBUG("%san assign\n", + yup_a_use && is_gimple_assign ( use_stmt) ? "" : "not "); + if ( TREE_CODE ( t) == SSA_NAME + && yup_a_use + && is_gimple_assign ( use_stmt) ) + { + tree use_lhs = gimple_assign_lhs ( use_stmt); + bt = base_type_of ( TREE_TYPE ( use_lhs)); + } + else + continue; + } + // find if in reorgtypes and get the info (in one call) ReorgType_t *ri = get_reorgtype_info ( bt, info); if ( ri != NULL && is_reorg_alloc_trigger ( stmt) ) { - //DEBUG_L( "Found allocaion: \n"); - //DEBUG_A( " Reorg: "); - //DEBUG_F( print_reorg, stderr, 0, ri); - //DEBUG("\n"); + DEBUG_L( "Found allocaion: \n"); + DEBUG_A( " Reorg: "); + DEBUG_F( print_reorg, stderr, 0, ri); + DEBUG("\n"); // TBD this needs to increment with the execution count // instead of one. I hope the build-in block count estimation // will work or a DIY solution might be called for. @@ -362,13 +384,13 @@ reorg_analysis ( Info *info) } } } - //INDENT(-2); + INDENT(-2); } } } - //DEBUG_L( "possible deletes:\n"); - //INDENT(2); + DEBUG_L( "possible deletes:\n"); + INDENT(2); // It's LOT more clear to use an iterator here TBD for ( int i = 0; i < info->reorg_type->size (); i++ ) { @@ -381,12 +403,13 @@ reorg_analysis ( Info *info) } // Note when multi-pools are enabled the test should be // "n == 0" but until then... + DEBUG_A("%d pools\n",n) if ( n != 1 ) { delete_reorgtype ( &(*(info->reorg_type))[i], info); } } - //INDENT(-2); + INDENT(-2); //DEBUG_L("after reorg_analysis\n"); remove_deleted_types ( info, &reorg_analysis_debug); @@ -822,7 +845,7 @@ disq_str_in_str_or_union_helper ( tree type, //tree base = base_type_of ( field_type); if ( TREE_CODE ( field_type) == RECORD_TYPE ) // base to field type { - //DEBUG( "RECORD\n"); + DEBUG( "RECORD\n"); ReorgType_t *rinfo = get_reorgtype_info ( field_type, info); // base to field type if ( rinfo != NULL ) @@ -1075,6 +1098,8 @@ modify_declarations ( Info *info) static void disqualify_all_reorgtypes_of ( gimple *stmt, int num, Info *info) { + DEBUG_L("disqualify_all_reorgtypes_of: "); + DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); int i; for ( i = 0; i < num; i++ ) { @@ -1404,14 +1429,14 @@ modify_decl_core ( tree *location, Info *info) 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"); + DEBUG( "TO DELETE\n"); info->num_deleted++; rt->delete_me = true; } else { - //DEBUG( "SKIP\n"); + DEBUG( "SKIP\n"); } } diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index 286e57c2380..8454c42dd89 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -253,7 +253,7 @@ extern bool print_internals (gimple *, void *); // defined marcos in the code. However, some of uses // should obviously be converted to dump file information. -#define DEBUGGING 1 +#define DEBUGGING 0 #if DEBUGGING enum Display { Show_nothing, -- cgit v1.2.3