summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-06-26 20:17:55 -0700
committerGary Oblock <gary@amperecomputing.com>2020-06-26 20:22:53 -0700
commit2b2c13e5d5a3aa7593ff9d79b21809f8b3b13239 (patch)
treed598b3d2fdcd290b3eeede186f6bbbd3050c59e0
parentb59eeed4972277b9f2144ce4d6e97e39b4a58f76 (diff)
Dangling ssa temps are now delt with.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c166
-rw-r--r--gcc/ipa-structure-reorg.c2
2 files changed, 126 insertions, 42 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index e21554da887..527b3ddb3e3 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -73,9 +73,12 @@ str_reorg_instance_interleave_qual ( Info *info)
int
str_reorg_instance_interleave_trans ( Info *info)
{
-
- DEBUG_L("Start of str_reorg_instance_interleave_trans:\n");
- DEBUG_F( print_program, stderr, 4);
+ 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, 4);
+ }
+
struct cgraph_node *node;
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) {
struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
@@ -476,6 +479,10 @@ str_reorg_instance_interleave_trans ( Info *info)
make_temp_ssa_name( field_type, NULL, "field_val_temp");
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");
// For either case generate common code:
@@ -1109,8 +1116,8 @@ str_reorg_instance_interleave_trans ( Info *info)
//gsi_insert_after( &gsi, gbad_field, GSI_SAME_STMT);
#endif
- DEBUG_L("End of malloc:\n");
- DEBUG_F( print_program, stderr, 4);
+ //DEBUG_L("End of malloc:\n");
+ //DEBUG_F( print_program, stderr, 4);
}
#endif
INDENT(-2);
@@ -1319,52 +1326,129 @@ str_reorg_instance_interleave_trans ( Info *info)
pop_cfun ();
}
- // TBD A mini-pass to fixup dangling SSA temps
+ // TBD A mini-pass to fixup dangling SSA temps. We need to modidy
+ // function parameter too before we do that.
// is run here.
- 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_stmt_iterator gsi;
- for ( gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) )
+ int mini_pass; // Passes 0 and two are just for testing
+ for ( mini_pass = 0; mini_pass < 3; mini_pass++ )
+ {
+ bool emit_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 *stmt = gsi_stmt ( gsi);
- if ( gimple_code ( stmt) == GIMPLE_ASSIGN )
+ gimple_stmt_iterator gsi;
+ for ( gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) )
{
- ReorgType_t *ri = contains_a_reorgtype( stmt, info);
- if ( ri != NULL )
+ gimple *stmt = gsi_stmt ( gsi);
+ if ( gimple_code ( stmt) == GIMPLE_ASSIGN )
{
- tree lhs = gimple_assign_lhs( stmt);
- tree rhs = gimple_assign_rhs1( stmt);
- bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info);
- bool rhs_reorg = tree_contains_a_reorgtype_p ( rhs, info);
-
- if ( lhs_reorg || rhs_reorg )
- {
- print_gimple_stmt ( stderr, stmt, 0);
- }
- if ( lhs_reorg )
- {
- fprintf( stderr, " LHS: ");
- print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0);
- fprintf( stderr, " ");
- }
- if ( rhs_reorg )
+ ReorgType_t *ri = contains_a_reorgtype( stmt, info);
+ if ( ri != NULL )
{
- fprintf( stderr, "%s RHS: ", lhs_reorg ? "," : "");
- print_generic_expr ( stderr, TREE_TYPE ( rhs), (dump_flags_t)0);
- fprintf( stderr, "\n");
+ 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 || rhs1_reorg || rhs2_reorg|| rhs3_reorg)
+ {
+ if ( emit_header )
+ {
+ emit_header = false;
+ fprintf( stderr, "SANITY CHECKING FAILURE:\n");
+ }
+ print_gimple_stmt ( stderr, stmt, 0);
+ }
+ if ( lhs_reorg )
+ {
+ fprintf( stderr, " LHS%s: ", lhs_ssa ? "*" : "");
+ print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0);
+ fprintf( stderr, " ");
+ }
+ if ( rhs1_reorg )
+ {
+ fprintf( stderr, "%s RHS1%s: ", lhs_reorg ? ", " : "",
+ rhs1_ssa ? "*" : "");
+ print_generic_expr ( stderr, TREE_TYPE ( rhs1), (dump_flags_t)0);
+ }
+ if ( rhs2_reorg )
+ {
+ 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 )
+ {
+ 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 )
+ {
+ tree lhs_type = TREE_TYPE ( lhs);
+ tree bottom_type = base_type_of ( lhs_type);
+ DEBUG_L("lhs: ");
+ DEBUG_F(print_generic_expr, stderr, lhs, (dump_flags_t)0);
+ DEBUG("\n");
+ DEBUG_L("bottom_type: ");
+ DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
+ DEBUG("\n");
+
+ ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
+ tree prev_type = lhs_type;
+ tree type = TREE_TYPE ( prev_type);
+ DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
+ for (; TREE_CODE ( type) == POINTER_TYPE; )
+ {
+ prev_type = type;
+ type = TREE_TYPE ( prev_type);
+ DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
+ }
+ // 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;
+ }
+ }
}
- // etc.
-
}
}
}
+ pop_cfun ();
}
- pop_cfun ();
+ }
+
+ if ( info->show_all_reorg_cands )
+ {
+ fprintf ( info->reorg_dump_file, "End of str_reorg_instance_interleave_trans:\n");
+ print_program ( info->reorg_dump_file, 4);
}
}
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index e22770641e8..c8a6d742c3a 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -1824,7 +1824,7 @@ print_function ( FILE *file, int leading_space, struct function *func)
gimple *stmt = gsi_stmt ( gsi);
fprintf ( file, "%*s", leading_space + 2, "" );
// Issue: for "if" this does not print the gotos.
- print_gimple_stmt ( file, stmt, 0, (dump_flags_t)0);
+ print_gimple_stmt ( file, stmt, 0, TDF_DETAILS);
}
}
}