diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-07-09 00:11:32 -0700 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-07-09 00:11:32 -0700 |
commit | 39a24f9cf7602f9077b262494335cc339a9cf76a (patch) | |
tree | 86184fd36b7dbf0bbf1b9b021d63f73241fcd29a | |
parent | 061e06f24817635ee21f807930b50b6d28d7748b (diff) |
Operand type bug fixes.
Added print_detailed_reorgs. Adds field name and types to print_reorgs
output.
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 110 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.c | 54 |
2 files changed, 105 insertions, 59 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index d71f6e051ea..cc2969ab598 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -266,9 +266,9 @@ str_reorg_instance_interleave_trans ( Info *info) // index = a tree index = - make_temp_ssa_name( ri->pointer_rep, NULL, "index"); + make_temp_ssa_name( sizetype, NULL, "index"); gimple *get_index = - gimple_build_assign( index, inner_op); + gimple_build_assign( index, CONVERT_EXPR, inner_op); SSA_NAME_DEF_STMT ( index) = get_index; gimple *temp_set; @@ -287,7 +287,7 @@ str_reorg_instance_interleave_trans ( Info *info) make_temp_ssa_name( base_field_type, NULL, "field_addr"); gimple *get_field_addr = - gimple_build_assign ( field_addr, PLUS_EXPR, field_arry_addr, offset); + gimple_build_assign ( field_addr, POINTER_PLUS_EXPR, field_arry_addr, offset); SSA_NAME_DEF_STMT ( field_addr) = get_field_addr; if ( ro_on_left ) @@ -445,25 +445,43 @@ str_reorg_instance_interleave_trans ( Info *info) // not reflected here. Punting and assigning the types to // the type of pointer_sized_int_node is probably not correct // even though that's the representation. - + + tree offset_type = TREE_TYPE ( TYPE_SIZE_UNIT (ri->gcc_type)); tree type = ri->pointer_rep; - tree tmp = make_temp_ssa_name( type, NULL, "PtrPlusInt"); + tree ptrplusint_adj = make_temp_ssa_name( type, NULL, "PtrPlusInt_Adj"); tree str_siz = build_int_cst ( type, int_cst_value ( TYPE_SIZE_UNIT (ri->gcc_type))); + tree rhs1 = gimple_assign_rhs1( stmt); tree rhs2 = gimple_assign_rhs2( stmt); - gimple *adjust_stmt = - gimple_build_assign ( tmp, TRUNC_DIV_EXPR, rhs2, str_siz); - SSA_NAME_DEF_STMT ( tmp) = adjust_stmt; + tree PPI_rhs2_cast = make_temp_ssa_name( type, NULL, "PPI_rhs2_cast"); + gimple *gPPI_rhs2_cast = gimple_build_assign ( PPI_rhs2_cast, CONVERT_EXPR, rhs2); + SSA_NAME_DEF_STMT ( PPI_rhs2_cast) = gPPI_rhs2_cast; + + gimple *gptrplusint_adj = + gimple_build_assign ( ptrplusint_adj, TRUNC_DIV_EXPR, PPI_rhs2_cast, str_siz); + SSA_NAME_DEF_STMT ( ptrplusint_adj) = gptrplusint_adj; // Note, gimple_set_op is used in limited places so using it - // to modify existed code might be problematic. - gimple_set_op( stmt, 2, tmp); + // to modify existed code might be problematic. NOOOOOOOOOOOOOOOOOO!!!!!!! + // TBD <================================================================== + // Build a regular add expression here using the desination of stmt and its + // first operand along with the new second operand. + tree ptrplusint = make_temp_ssa_name( type, NULL, "PtrPlusInt"); + gimple *gptrplusint = + gimple_build_assign ( ptrplusint, PLUS_EXPR, rhs1, ptrplusint_adj); + SSA_NAME_DEF_STMT ( ptrplusint) = gptrplusint; + + //gimple_set_op( stmt, 2, tmp); gimple_stmt_iterator gsi = gsi_for_stmt( stmt); - gsi_insert_before( &gsi, adjust_stmt, GSI_SAME_STMT); + gsi_insert_before( &gsi, gPPI_rhs2_cast, GSI_SAME_STMT); + gsi_insert_before( &gsi, gptrplusint_adj, GSI_SAME_STMT); + gsi_insert_before( &gsi, gptrplusint, GSI_SAME_STMT); + + gsi_remove ( &gsi, true); DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, adjust_stmt, 0); + DEBUG_F( print_gimple_stmt, stderr, gptrplusint_adj, 0); DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, stmt, 0); + DEBUG_F( print_gimple_stmt, stderr, gptrplusint, 0); } break; @@ -560,18 +578,22 @@ str_reorg_instance_interleave_trans ( Info *info) //tree len = make_temp_ssa_name( sizetype, NULL, "fail_val"); // The above segfaulted ??? note, it's not an idiom seen in gcc tree int_ptrsize_type = signed_type_for ( ptr_type_node); - DEBUG_L("int_ptrsize_type = %p\n", int_ptrsize_type); - tree len = make_temp_ssa_name ( int_ptrsize_type, NULL, "malloc_len"); + DEBUG_L("int_ptrsize_type = %p\n", TREE_TYPE ( size)); + tree len = make_temp_ssa_name ( TREE_TYPE ( size), NULL, "malloc_len"); gimple_stmt_iterator gsi = gsi_for_stmt( stmt); //gimple *glen = // gimple_build_assign ( len, TRUNC_DIV_EXPR, val, size); - // This makes me nervous... - TREE_TYPE (len) = TREE_TYPE ( size); + // Cast arg to compatible type TREE_TYPE (arg) = TREE_TYPE ( size); + tree cast_arg = + make_temp_ssa_name( TREE_TYPE ( size), NULL, "cast_arg"); + gimple *gcast_arg = gimple_build_assign ( cast_arg, CONVERT_EXPR, arg); + SSA_NAME_DEF_STMT ( cast_arg) = gcast_arg; + gsi_insert_before( &gsi, gcast_arg, GSI_SAME_STMT); gimple *glen = - gimple_build_assign ( len, TRUNC_DIV_EXPR, arg, size); + gimple_build_assign ( len, TRUNC_DIV_EXPR, cast_arg, size); SSA_NAME_DEF_STMT ( len) = glen; gsi_insert_before( &gsi, glen, GSI_SAME_STMT); @@ -616,15 +638,20 @@ str_reorg_instance_interleave_trans ( Info *info) // Now it's safe to remove it! gsi_remove ( &gsi, true); - tree malloc_return_type = TREE_TYPE ( arg); - tree fail_val = - make_temp_ssa_name ( malloc_return_type, NULL, "malloc_fail_val"); + tree field; tree reorg_type = ri->gcc_type; // is this useful here? tree reorg_pointer_type = ri->pointer_rep; //tree base = ri->reorg_ver_type; //nopers tree base = ri->instance_interleave.base; + // ??? We are faking the malloc so the following seemed dubious + //tree malloc_return_type = TREE_TYPE ( arg); + //tree fail_val = + // make_temp_ssa_name ( malloc_return_type, NULL, "malloc_fail_val"); + tree fail_val = + make_temp_ssa_name ( reorg_pointer_type, NULL, "malloc_fail_val"); + // loop setup trickery for gimple idioms // // FROM prev_order = failure_bb @@ -650,12 +677,6 @@ str_reorg_instance_interleave_trans ( Info *info) field; field = DECL_CHAIN( field)) { - // FROM res is new SSA - // Note, alternative code would substitute ptr_type_node - // for null_pointer_node. - // This is probably a duplicate of the def of res below. - //tree res = - // make_temp_ssa_name( null_pointer_node, NULL, "res"); basic_block new_bb = create_empty_bb ( prev_order); new_bb->count = prev_order->count; @@ -663,7 +684,6 @@ str_reorg_instance_interleave_trans ( Info *info) // Note, switching the order of edge creation and // setting dominator seems to make no difference // TBD set edge probability and flags - // VERIFIED EDGE_TRUE_VALUE // edge_flags depends on whether or not the predecessor // block was created in this loop. edge ok_edge = make_edge ( prev_bb, new_bb, edge_flags); @@ -677,7 +697,6 @@ str_reorg_instance_interleave_trans ( Info *info) //set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb); // TBD set edge probability and flags - // VERIFIED EDGE_FALSE_VALUE edge fail_edge = make_edge ( new_bb, failure_bb, EDGE_FALSE_VALUE); fail_edge->probability = profile_probability::very_unlikely (); fail_edge->count () = new_bb->count - new_bb->count; @@ -689,7 +708,6 @@ str_reorg_instance_interleave_trans ( Info *info) tree res = make_temp_ssa_name ( ptr_type_node, NULL, "res"); - // VERIFIED new_ok_field_L,bad_field_L gimple *gcond = gimple_build_cond ( NE_EXPR, res, null_pointer_node, #if USE_LABELS @@ -748,6 +766,7 @@ str_reorg_instance_interleave_trans ( Info *info) make_temp_ssa_name( sizetype, NULL, "malloc_mem_size"); 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; gsi_insert_after( &gsi, malloc_call, GSI_SAME_STMT); cgraph_node::get ( cfun->decl)-> @@ -763,16 +782,15 @@ str_reorg_instance_interleave_trans ( Info *info) // gimple_build_assign ( mem_size, MULT_EXPR, TYPE_SIZE(field), // len, NULL_TREE, NULL_TREE); - // This make me nervous (and breaks things) - //tree field_size = TYPE_SIZE ( TREE_TYPE ( field)); - //TREE_TYPE ( field_size) = TREE_TYPE ( mem_size); - // We need field_size to be of the correct type so... + // We need field_size to be of the correct type so + // we type cast. tree field_size = make_temp_ssa_name( TREE_TYPE ( mem_size), NULL, "field_size"); gimple *gfield_size = gimple_build_assign ( field_size, CONVERT_EXPR, TYPE_SIZE ( TREE_TYPE ( field))); + SSA_NAME_DEF_STMT ( field_size) = gfield_size; gimple *gsize = gimple_build_assign ( mem_size, @@ -785,13 +803,10 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_insert_after ( &gsi, gfield_size, GSI_SAME_STMT); - // Moved label to top - //// FROM gsi_insert_after( &gsi, prev_ok_field) - //gimple *gprev_ok_field = gimple_build_label ( prev_ok_field_L); - //gsi_insert_after ( &gsi, gprev_ok_field, GSI_SAME_STMT); prev_bb = new_bb; prev_order = new_bb; #if USE_LABELS + // Moved label to top prev_ok_field_L = new_ok_field_L; #endif } @@ -812,7 +827,6 @@ str_reorg_instance_interleave_trans ( Info *info) //set_immediate_dominator ( CDI_DOMINATORS, success_bb, prev_bb); // TBD set edge probability and flags - // VERIFIED EDGE_TRUE_VALUE edge success_e = make_edge ( prev_bb, success_bb, EDGE_TRUE_VALUE ); edge succ_to_after_e = make_edge ( success_bb, after_bb, EDGE_FALLTHRU); success_e->probability = profile_probability::very_likely (); @@ -870,7 +884,7 @@ str_reorg_instance_interleave_trans ( Info *info) gphi *der_phi = create_phi_node( val, after_bb); // OPS! //add_phi_arg( der_phi, success_val, success_edge, UNKNOWN_LOCATION); - add_phi_arg( der_phi, fail_val, succ_to_after_e, UNKNOWN_LOCATION); + add_phi_arg( der_phi, success_val, succ_to_after_e, UNKNOWN_LOCATION); add_phi_arg( der_phi, fail_val, fail_to_after_e, UNKNOWN_LOCATION); //// FROM gsi_insert_after( &gsi, after_label) @@ -922,10 +936,11 @@ str_reorg_instance_interleave_trans ( Info *info) gimple *gzero = gimple_build_assign( lhs_ass, null_pointer_node); gsi_insert_after( &gsi, gzero, GSI_SAME_STMT); - // FROM gsi_insert_after( &gsi, "free(field)") - // TBD -- I'm + // Tried reorg_pointer_type + //tree to_free = + // make_temp_ssa_name( reorg_pointer_type, NULL, "malloc_to_free"); tree to_free = - make_temp_ssa_name( reorg_pointer_type, NULL, "malloc_to_free"); + make_temp_ssa_name( ptr_type_node, NULL, "malloc_to_free"); gcall *free_call = gimple_build_call( fndecl_free, 1, to_free); gsi_insert_after( &gsi, free_call, GSI_SAME_STMT); @@ -949,9 +964,8 @@ str_reorg_instance_interleave_trans ( Info *info) } // FROM gsi_insert_after( &gsi, "fail_val = minint") gimple *gretnull = - gimple_build_assign ( fail_val, - //build_int_cst ( size_type_node, - TYPE_MIN_VALUE ( TREE_TYPE ( fail_val))); // ); + gimple_build_assign ( fail_val, CONVERT_EXPR, + TYPE_MIN_VALUE ( TREE_TYPE ( fail_val))); SSA_NAME_DEF_STMT ( fail_val) = gretnull; gsi_insert_after( &gsi, gretnull, GSI_SAME_STMT); @@ -1539,9 +1553,7 @@ create_a_new_type ( Info_t *info, tree type) reorg_type->pointer_rep = pointer_rep; */ - tree pointer_rep = make_node ( INTEGER_TYPE); - TYPE_PRECISION ( pointer_rep) = - TYPE_PRECISION ( pointer_sized_int_node); + tree pointer_rep = make_signed_type ( TYPE_PRECISION ( pointer_sized_int_node)); //DEBUG("Issue with gcc_ of reorg\n"); //DEBUG_F(print_reorg, stderr, 2, ri); const char *gcc_name = diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index a60f111a01d..f20336d4e2e 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -85,6 +85,7 @@ static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info *); //static void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *); static void dump_reorg ( ReorgType_t *reorg); static void print_reorgs ( FILE *, int, Info *); +static void print_detailed_reorgs ( FILE *, int, Info *); //static void print_reorg ( FILE *, int, ReorgType_t *); static void print_progdecls ( FILE *, int, Info *); static void print_progdecl ( FILE *, int, ProgDecl_t *); @@ -156,7 +157,7 @@ ipa_structure_reorg ( void) if ( info.show_all_reorg_cands_in_detail ) { fprintf ( info.reorg_dump_file, "Qualified the following types:\n"); - print_reorgs ( info.reorg_dump_file, 2, &info); + print_detailed_reorgs ( info.reorg_dump_file, 2, &info); } reorg_common_middle_code( &info); // ??? might not amount to anything @@ -1735,15 +1736,7 @@ dump_reorg ( ReorgType_t *reorg) } void -print_reorgs ( FILE *file, int leading_space, Info *info) -{ - for ( int i = 0; i < info->reorg_type->size (); i++ ) { - print_reorg ( file, leading_space, &(*(info->reorg_type))[i]); - } -} - -void -print_reorg ( FILE *file, int leading_space, ReorgType_t *reorg ) +print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detailed ) { // TBD // note if reorg_perf & regular_perf are nonzero @@ -1792,6 +1785,47 @@ print_reorg ( FILE *file, int leading_space, ReorgType_t *reorg ) } fprintf ( file, "}\n"); + if ( detailed ) + { + tree field; + for ( field = TYPE_FIELDS( reorg->reorg_ver_type); + field; + field = DECL_CHAIN( field)) + { + fprintf ( file, "%*s", leading_space + 4, ""); + print_generic_expr ( stderr, field, (dump_flags_t)0); + fprintf ( stderr, ": "); + print_generic_expr ( stderr, TREE_TYPE ( field), (dump_flags_t)0); + fprintf ( stderr, "\n"); + } + } +} + +static void +print_base_reorgs ( FILE *file, int leading_space, Info *info, bool detailed) +{ + for ( int i = 0; i < info->reorg_type->size (); i++ ) { + print_base_reorg ( file, leading_space, &(*(info->reorg_type))[i], detailed); + } +} + + +static void +print_detailed_reorgs (FILE *file, int leading_space, Info *info) +{ + print_base_reorgs ( file, leading_space, info, true); +} + +static void +print_reorgs ( FILE *file, int leading_space, Info *info) +{ + print_base_reorgs ( file, leading_space, info, false); +} + +void +print_reorg ( FILE *file, int leading_space, ReorgType_t *reorg ) +{ + print_base_reorg ( file, leading_space, reorg, false); } static void |