diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-08-12 18:13:03 -0700 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-08-12 18:13:03 -0700 |
commit | e59761f5fdda5e70c530e0906b09f690fc243f44 (patch) | |
tree | 29632bc4ed2d95dc2b88fa90003b7d4ee5dfec09 /gcc/ipa-str-reorg-instance-interleave.c | |
parent | 0a944b8d2e0981127d0ee3f0db85000a804dcad0 (diff) |
A little clean up of the code.
Diffstat (limited to 'gcc/ipa-str-reorg-instance-interleave.c')
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 378 |
1 files changed, 39 insertions, 339 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index db5d323a8cf..168204d2346 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -65,10 +65,8 @@ static void remove_default_def ( tree, struct function *); #define REORG_SP_PREFIX "_reorg_base_type_" #define REORG_SP_BASE_PREFIX "_reorg_base_var_" -// We use labels and gotos. This is incorrect but -// for now it better shows the structure of the code emitted. -#define USE_LABELS 0 - +// TBD Delete all this after sending a note on it +// to the gcc mailing list. #define USE_BUILT_IN_FREE 1 int @@ -245,9 +243,9 @@ str_reorg_instance_interleave_trans ( Info *info) tree inner_op = TREE_OPERAND( ro_side, 0); inner_op = TREE_OPERAND( inner_op, 0); - DEBUG_L("inner_op: "); - DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)0); - DEBUG("\n"); + //DEBUG_L("inner_op: "); + //DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)0); + //DEBUG("\n"); // For either case generate common code: @@ -330,19 +328,7 @@ str_reorg_instance_interleave_trans ( Info *info) // With: lhs = a->f // Generate: - // temp = *field_addr - // INDIRECT_REF is not supported fot GIMPLE... sigh... - // tree rhs_ref = build1 ( INDIRECT_REF, field_type, field_addr); - - // This doesn't work - //tree rhs_ref = build2 ( MEM_REF, - // base_field_type, base_field, offset); - - // Niether does this it dies on the offset - //tree rhs_ref = build2 ( MEM_REF, - // field_type, base_field, offset); - - // This idiom seems to work (WTF?!) + // Tried other idioms here (tricky) tree rhs_ref = build2 ( MEM_REF, field_type, field_addr, build_int_cst (ptr_type_node, 0)); @@ -356,19 +342,6 @@ str_reorg_instance_interleave_trans ( Info *info) tree op1 = TREE_OPERAND ( rhs_ref, 1); tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1)); tree op1type_type = TREE_TYPE ( op1type); - DEBUG_L("op0: "); - DEBUG_F(print_generic_expr, stderr, op0, (dump_flags_t)0); - DEBUG("\n") - DEBUG_L("op1: "); - DEBUG_F(print_generic_expr, stderr, op1, (dump_flags_t)0); - DEBUG("\n") - DEBUG_L("op1type: "); - DEBUG_F(print_generic_expr, stderr, op1type, (dump_flags_t)0); - DEBUG("\n"); - DEBUG_L("op1type_type: %p\n", op1type_type); - DEBUG_L("op1type_type: "); - DEBUG_F(print_generic_expr, stderr, op1type_type, (dump_flags_t)0); - DEBUG("\n") temp_set = gimple_build_assign( field_val_temp, rhs_ref); @@ -379,29 +352,29 @@ str_reorg_instance_interleave_trans ( Info *info) SSA_NAME_DEF_STMT ( lhs) = final_set; } - DEBUG_L("get_field_arry_addr: "); - DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0); - DEBUG("\n"); + //DEBUG_L("get_field_arry_addr: "); + //DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0); + //DEBUG("\n"); - DEBUG_L("get_index: "); - DEBUG_F( print_gimple_stmt, stderr, get_index, 0); - DEBUG("\n"); + //DEBUG_L("get_index: "); + //DEBUG_F( print_gimple_stmt, stderr, get_index, 0); + //DEBUG("\n"); - DEBUG_L("get_offset: "); - DEBUG_F( print_gimple_stmt, stderr, get_offset, 0); - DEBUG("\n"); + //DEBUG_L("get_offset: "); + //DEBUG_F( print_gimple_stmt, stderr, get_offset, 0); + //DEBUG("\n"); - DEBUG_L("get_field_addr: "); - DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0); - DEBUG("\n"); + //DEBUG_L("get_field_addr: "); + //DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0); + //DEBUG("\n"); - DEBUG_L("temp_set: "); - DEBUG_F( print_gimple_stmt, stderr, temp_set, 0); - DEBUG("\n"); + //DEBUG_L("temp_set: "); + //DEBUG_F( print_gimple_stmt, stderr, temp_set, 0); + //DEBUG("\n"); - DEBUG_L("final_set: "); - DEBUG_F( print_gimple_stmt, stderr, final_set, 0); - DEBUG("\n"); + //DEBUG_L("final_set: "); + //DEBUG_F( print_gimple_stmt, stderr, final_set, 0); + //DEBUG("\n"); gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT); gsi_insert_before( &gsi, get_index, GSI_SAME_STMT); @@ -505,15 +478,14 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_remove ( &gsi, true); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPPI_rhs2_cast, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPPI_adj, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPPI, 0); - DEBUG_L(""); - DEBUG_F( print_gimple_stmt, stderr, gPPI_cast, 0); - + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPPI_rhs2_cast, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPPI_adj, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPPI, 0); + //DEBUG_L(""); + //DEBUG_F( print_gimple_stmt, stderr, gPPI_cast, 0); } break; case ReorgT_Ptr2Zero: // "a = 0" @@ -562,7 +534,6 @@ str_reorg_instance_interleave_trans ( Info *info) // Not needed for single pool. break; case ReorgT_Malloc: - #if 1 { DEBUG_L("Transform ReorgT_Malloc\n"); INDENT(2); @@ -645,14 +616,6 @@ str_reorg_instance_interleave_trans ( Info *info) basic_block after_bb = new_edge->dest; remove_edge ( new_edge); basic_block prev_bb = before_bb; - #if USE_LABELS - tree prev_ok_field_L = - create_artificial_label ( UNKNOWN_LOCATION); - tree after_label_L = - create_artificial_label ( UNKNOWN_LOCATION); - gimple *goto_pof = gimple_build_goto ( prev_ok_field_L); - gsi_insert_before ( &gsi, goto_pof, GSI_SAME_STMT); // TBD insert after??? - #endif // FROM failure_bb = create_empty_block(prev_bb) basic_block failure_bb = create_empty_bb ( prev_bb); @@ -666,17 +629,10 @@ str_reorg_instance_interleave_trans ( Info *info) fail_to_after_e->probability = profile_probability::very_unlikely (); fail_to_after_e->count () = failure_bb->count; - #if USE_LABELS - // FROM bad_field is new label - tree bad_field_L = - create_artificial_label ( UNKNOWN_LOCATION); - #endif - // Note, this should remove this call from the call graph cgraph_update_edges_for_call_stmt ( stmt, gimple_call_fndecl ( stmt), NULL); // Now it's safe to remove it! gsi_remove ( &gsi, true); - tree field; tree reorg_type = ri->gcc_type; // is this useful here? @@ -764,11 +720,6 @@ str_reorg_instance_interleave_trans ( Info *info) fail_edge->probability = profile_probability::very_unlikely (); fail_edge->count () = new_bb->count - new_bb->count; - #if USE_LABELS - new_ok_field_L = - create_artificial_label ( UNKNOWN_LOCATION); - #endif - //tree lhs_ass = // build3( COMPONENT_REF, ptr_type_node, base, field, NULL_TREE); tree lhs_ass = build3( COMPONENT_REF, @@ -814,9 +765,6 @@ str_reorg_instance_interleave_trans ( Info *info) make_temp_ssa_name( TREE_TYPE ( mem_size), NULL, "field_size"); // Move gprev_ok_field here - #if USE_LABELS - gimple *gprev_ok_field = gimple_build_label ( prev_ok_field_L); - #endif // Move gfield_size here gimple *gfield_size = @@ -871,20 +819,13 @@ str_reorg_instance_interleave_trans ( Info *info) // Move gcond here gimple *gcond = gimple_build_cond ( NE_EXPR, res, null_pointer_node, - #if USE_LABELS - new_ok_field_L, bad_field_L - #else NULL, NULL - #endif ); // Last is first gsi_insert_before ( &gsi, gcond, GSI_NEW_STMT); // The rest in order before the last - #if USE_LABELS - gsi_insert_before ( &gsi, gprev_ok_field, GSI_SAME_STMT); - #endif gsi_insert_before ( &gsi, gfield_size, GSI_SAME_STMT); gsi_insert_before ( &gsi, gsize, GSI_SAME_STMT); gsi_insert_before ( &gsi, malloc_call, GSI_SAME_STMT); @@ -893,10 +834,6 @@ str_reorg_instance_interleave_trans ( Info *info) prev_bb = new_bb; prev_order = new_bb; - #if USE_LABELS - // Moved label to top - prev_ok_field_L = new_ok_field_L; - #endif } // Loop cleaup fo failure code bb here. There is loop state @@ -930,16 +867,9 @@ str_reorg_instance_interleave_trans ( Info *info) gsi = gsi_start_bb ( success_bb); // used to be failure_bb - #if USE_LABELS - // Emit the label first and then everything else after it - gimple *gnew_ok_field = gimple_build_label ( new_ok_field_L); - gsi_insert_after ( &gsi, gnew_ok_field, GSI_NEW_STMT); - gimple *goto_al_succ = gimple_build_goto( after_label_L); - gsi_insert_after( &gsi, goto_al_succ, GSI_SAME_STMT); - #else + // TBD Rewrite to not emit a nop here. gimple *dummy = gimple_build_nop (); gsi_insert_after ( &gsi, dummy, GSI_NEW_STMT); - #endif gimple *set_succ = gimple_build_assign ( success_val, @@ -958,13 +888,6 @@ str_reorg_instance_interleave_trans ( Info *info) //gimple_stmt_iterator gsi = gsi_start_bb( after_bb); gsi = gsi_start_bb( after_bb); - #if USE_LABELS - // put the label first - // FROM gsi_insert_after( &gsi, after_label) - gimple *gafter_label = gimple_build_label( after_label_L); - gsi_insert_after( &gsi, gafter_label, GSI_NEW_STMT); - #endif - // FROM gsi_insert_after( &gsi, "lhs = "phi(success_val, fail_val) // Note, BBs have a sequence of phis which create_phi_node takes care of @@ -980,19 +903,15 @@ str_reorg_instance_interleave_trans ( Info *info) gimple_build_assign ( val, CONVERT_EXPR, m_phi_val); SSA_NAME_DEF_STMT ( val) = gm_cast_phi_val; - #if USE_LABELS - gsi_insert_after( &gsi, gm_cast_phi_val, GSI_SAME_STMT); - #else gsi_insert_after( &gsi, gm_cast_phi_val, GSI_NEW_STMT); - #endif //// FROM gsi_insert_after( &gsi, after_label) //gimple *gafter_label = gimple_build_label( after_label_L); //gsi_insert_after( &gsi, gafter_label, GSI_SAME_STMT); - // Try failure_bb code here - #if 1 + // failure_bb code here + // if defed on here... moved this // code in failure_bb // @@ -1003,19 +922,9 @@ str_reorg_instance_interleave_trans ( Info *info) // FROM gsi = gsi_start_bb ( failure_bb) gsi = gsi_start_bb ( failure_bb); - #if USE_LABELS - // Put the label first - // FROM gsi_insert_after( &gsi, bad_field ) - gimple *gbad_field = gimple_build_label( bad_field_L); - gsi_insert_after( &gsi, gbad_field, GSI_NEW_STMT); - - // FROM gsi_insert_after ( &gsi, "goto after_label") - gimple *goto_al = gimple_build_goto ( after_label_L); - gsi_insert_after ( &gsi, goto_al, GSI_SAME_STMT); - #else + // TBD Rewrite to not emit nops! gimple *dummy_fail = gimple_build_nop (); gsi_insert_after ( &gsi, dummy_fail, GSI_NEW_STMT); - #endif // (per field) { //tree field; // defined above @@ -1088,14 +997,10 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_insert_after( &gsi, gretnull, GSI_SAME_STMT); //// FROM gsi_insert_after( &gsi, bad_field ) - //gimple *gbad_field = gimple_build_label( bad_field_L); - //gsi_insert_after( &gsi, gbad_field, GSI_SAME_STMT); - #endif //DEBUG_L("End of malloc:\n"); //DEBUG_F( print_program, PRINT_FORMAT, stderr, 4); } - #endif INDENT(-2); break; case ReorgT_Calloc: @@ -1321,7 +1226,6 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG_L("after bulk of transformations\n"); - #if NEW_SSA_SCHEME // New technique // A mini-pass to fixup dangling SSA temps. // TBD Important, transform all fuction decls @@ -1419,14 +1323,6 @@ str_reorg_instance_interleave_trans ( Info *info) // new default def FOR_EACH_IMM_USE_STMT ( stmt, iter, old_default_def) { - #if 0 - FOR_EACH_IMM_USE_ON_STMT ( use, iter) - { - SET_USE ( use, new_default_def); - } - // Possibly do this??? - //update_stmt ( stmt); - #else DEBUG_A("before: "); DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); use_operand_p use_p; @@ -1443,14 +1339,11 @@ str_reorg_instance_interleave_trans ( Info *info) } DEBUG_A("after: "); DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); - #endif } // Get rid of the old default def because it confuses // remove_default_def ( old_default_def, func); } - - } } INDENT(-4); @@ -1614,181 +1507,6 @@ str_reorg_instance_interleave_trans ( Info *info) pop_cfun (); } - #else - // TBD A mini-pass to fixup dangling SSA temps. We need to modidy - // function parameter too before we do that. - int mini_pass; // Passes 0 and 2 are just for testing - for ( mini_pass = 0; mini_pass < 3; mini_pass++ ) - { - header ( true); - FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) { - struct function *func = DECL_STRUCT_FUNCTION ( node->decl); - // Ulgy GCC idiom with global pointer to current function. - push_cfun ( func); - basic_block bb; - FOR_EACH_BB_FN ( bb, func) - { - gimple_seq seq = bb->il.gimple.phi_nodes; - if ( seq ) - { - gimple_stmt_iterator phii; - for ( phii = gsi_start (seq); !gsi_end_p (phii); gsi_next (&phii)) - { - gimple *phi_stmt = gsi_stmt ( phii); - if ( contains_a_reorgtype( phi_stmt, info) ) - { - tree lhs = gimple_assign_lhs( phi_stmt); - if ( tree_contains_a_reorgtype_p ( lhs, info) ) - { - if ( mini_pass == 0 || mini_pass == 2 ) - { - header ( false); - fprintf( stderr, " LHS: "); - print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0); - fprintf( stderr, " "); - } - else - { - wrangle_ssa_type ( lhs, info); - } - } - - // Wrangle the right hand side - unsigned num; - num = gimple_num_ops ( phi_stmt); - unsigned i; - for ( i = 1; i < num; i++ ) - { - tree *op = gimple_op_ptr ( phi_stmt, i); - if ( tree_contains_a_reorgtype_p ( *op, info) ) - { - if ( mini_pass == 0 || mini_pass == 2 ) - { - header ( false); - fprintf( stderr, " RHS%d: ", i); - print_generic_expr ( stderr, TREE_TYPE ( *op), (dump_flags_t)0); - fprintf( stderr, " "); - } - else - { - wrangle_ssa_type ( *op, info); - } - } - } - } - } - } - - if ( mini_pass == 1 ) - { - DEBUG_L("after phi wrangling\n"); - } - - gimple_stmt_iterator gsi; - for ( gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) ) - { - gimple *stmt = gsi_stmt ( gsi); - if ( gimple_code ( stmt) == GIMPLE_ASSIGN ) - { - ReorgType_t *ri = contains_a_reorgtype( stmt, info); - if ( ri != NULL ) - { - tree lhs = gimple_assign_lhs( stmt); - tree rhs1 = gimple_assign_rhs1( stmt); - tree rhs2 = gimple_assign_rhs2( stmt); - tree rhs3 = gimple_assign_rhs3( stmt); - - bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info); - bool rhs1_reorg = tree_contains_a_reorgtype_p ( rhs1, info); - bool rhs2_reorg = tree_contains_a_reorgtype_p ( rhs2, info); - bool rhs3_reorg = tree_contains_a_reorgtype_p ( rhs3, info); - - bool lhs_ssa = lhs_reorg && TREE_CODE(lhs) == SSA_NAME; - bool rhs1_ssa = rhs1_reorg && TREE_CODE(rhs1) == SSA_NAME; - bool rhs2_ssa = rhs2_reorg && TREE_CODE(rhs2) == SSA_NAME; - bool rhs3_ssa = rhs3_reorg && TREE_CODE(rhs3) == SSA_NAME; - - if ( mini_pass == 0 || mini_pass == 2 ) - { - if ( lhs_reorg ) - { - header ( false); - fprintf( stderr, " LHS%s: ", lhs_ssa ? "*" : ""); - print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0); - fprintf( stderr, " "); - } - if ( rhs1_reorg ) - { - header ( false); - fprintf( stderr, "%s RHS1%s: ", lhs_reorg ? ", " : "", - rhs1_ssa ? "*" : ""); - print_generic_expr ( stderr, TREE_TYPE ( rhs1), (dump_flags_t)0); - } - if ( rhs2_reorg ) - { - header ( false); - fprintf( stderr, "%s RHS2%s: ", - lhs_reorg || rhs1_reorg ? ", " : "", - rhs2_ssa ? "*" : ""); - print_generic_expr ( stderr, TREE_TYPE ( rhs2), (dump_flags_t)0); - } - if ( rhs3_reorg ) - { - header ( false); - fprintf( stderr, "%s RHS3%s: ", - lhs_reorg || rhs1_reorg || rhs2_reorg ? ", " : "", - rhs3_ssa ? "*" : ""); - print_generic_expr ( stderr, TREE_TYPE ( rhs3), (dump_flags_t)0); - } - if ( lhs_reorg || rhs1_reorg || rhs2_reorg || rhs3_reorg ) - { - fprintf( stderr, "\n"); - } - // etc. - } - if ( mini_pass == 1 ) - { - if ( lhs_ssa ) - { - wrangle_ssa_type ( lhs, info); - DEBUG_L("after lhs wrangle\n"); - } - if ( rhs1_ssa ) - { - DEBUG_L("rhs1: "); - DEBUG_F(print_generic_expr, stderr, rhs1, (dump_flags_t)0); - DEBUG("\n"); - wrangle_ssa_type( rhs1, info); - DEBUG_L("rhs1 after wrangle: "); - DEBUG_F(print_generic_expr, stderr, rhs1, (dump_flags_t)0); - DEBUG("\n"); - } - if ( rhs2_ssa ) - { - wrangle_ssa_type( rhs2, info); - } - if ( rhs3_ssa ) - { - wrangle_ssa_type( rhs3, info); - } - } - } - } - if ( mini_pass == 1 ) - { - DEBUG_L("after stmt: "); - DEBUG_F(print_gimple_stmt, stderr, stmt, 0); - } - } - if ( mini_pass == 1 ) - { - DEBUG_L("after gimple wrangling\n"); - } - } - pop_cfun (); - } - } - #endif DEBUG_L("after mini-passes\n"); @@ -2012,9 +1730,6 @@ create_new_types ( Info_t *info) } } -// An alternate method of creating a record type -#define FROM_HOOKS 1 - static void create_a_new_type ( Info_t *info, tree type) { @@ -2044,17 +1759,9 @@ create_a_new_type ( Info_t *info, tree type) ReorgType_t *ri = get_reorgtype_info ( type, info); if ( ri != NULL ) { - // From the comment of build_variant_type_copy it might not what - // is needed to here. Comment in tree: - // "Create a new variant of TYPE, equivalent but distinct." - // Now before we panic le'ts give it a try. - // - #if FROM_HOOKS + // Create the new record type of the reorg type tree reorg_type_prime = lang_hooks.types.make_type (RECORD_TYPE); - #else - tree reorg_type_prime = - build_variant_type_copy ( type MEM_STAT_DECL); - #endif + ri->reorg_ver_type = reorg_type_prime; DEBUG_L("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); @@ -2126,14 +1833,7 @@ create_a_new_type ( Info_t *info, tree type) TYPE_NAME ( reorg_type_prime) = get_identifier ( rec_name); tree field; tree new_fields = NULL; - for ( - #if FROM_HOOKS - field = TYPE_FIELDS ( type); - #else - field = TYPE_FIELDS ( reorg_type_prime); - #endif - field; - field = DECL_CHAIN ( field)) + for ( field = TYPE_FIELDS ( type); field; field = DECL_CHAIN ( field)) { //DEBUG_F( print_generic_decl, stderr, field, TDF_DETAILS); // example tree tree_type = TREE_TYPE ( field); |