summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-08-05 12:02:31 -0700
committerGary Oblock <gary@amperecomputing.com>2020-08-05 12:02:31 -0700
commitff6d2caf8bbbe5d7fb931aa55db406557a956e4a (patch)
tree91ca78f4da1f060d7196e359aa2c551d92462c51
parent0b078e460ea82c6cb6788e31151834b73c971e8f (diff)
Fixed multiple bugs.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c413
-rw-r--r--gcc/ipa-structure-reorg.c95
-rw-r--r--gcc/ipa-structure-reorg.h7
3 files changed, 473 insertions, 42 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index 746b63cf9cf..b205c2670ae 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -1,7 +1,7 @@
/* Interprocedural scalar replacement of aggregates
Copyright (C) 2019-2020 Free Software Foundation, Inc.
- Contributed by Gary Oblock <goblock@marvell.com>
+ Contributed by Gary Oblock <gary@amperecomputing.com>
This file is part of GCC.
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
+#include "tree-ssa.h"
+#include "tree-dfa.h"
#include "gimple.h"
#include "tree-pass.h"
#include "cgraph.h"
@@ -47,7 +49,7 @@ along with GCC; see the file COPYING3. If not see
#include "cfgloop.h"
static void wrangle_ssa_type( tree, Info_t*);
-static bool print_internals (gimple *, void *);
+//static bool print_internals (gimple *, void *);
static void str_reorg_instance_interleave_qual_part ( Info *);
static void str_reorg_instance_interleave_type_part ( Info *);
static void header ( bool);
@@ -84,7 +86,7 @@ str_reorg_instance_interleave_trans ( Info *info)
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, PRINT_FORMAT, 4);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info);
}
struct cgraph_node *node;
@@ -233,6 +235,7 @@ str_reorg_instance_interleave_trans ( Info *info)
tree base_field_type = TREE_TYPE( base_field);
+ gcc_assert ( field_type);
tree field_val_temp =
make_temp_ssa_name( field_type, NULL, "field_val_temp");
@@ -245,6 +248,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// For either case generate common code:
// field_array = _base.f
+ gcc_assert ( base_field_type);
tree field_arry_addr =
make_temp_ssa_name( base_field_type, NULL, "field_arry_addr");
@@ -266,6 +270,7 @@ str_reorg_instance_interleave_trans ( Info *info)
SSA_NAME_DEF_STMT ( field_arry_addr) = get_field_arry_addr;
// index = a
+ gcc_assert ( sizetype);
tree index =
make_temp_ssa_name( sizetype, NULL, "index");
gimple *get_index =
@@ -277,6 +282,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// offset = index * size_of_field
tree size_of_field = TYPE_SIZE_UNIT ( base_field_type);
+ gcc_assert ( sizetype);
tree offset = make_temp_ssa_name( sizetype, NULL, "offset"); // TBD sizetype ???
gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
@@ -284,6 +290,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// field_addr = field_array + offset
// bug fix here (TBD) type must be *double not double
+ gcc_assert ( base_field_type);
tree field_addr =
make_temp_ssa_name( base_field_type, NULL, "field_addr");
@@ -457,7 +464,8 @@ str_reorg_instance_interleave_trans ( Info *info)
tree rhs1 = gimple_assign_rhs1( stmt);
tree rhs2 = gimple_assign_rhs2( stmt);
-
+
+ gcc_assert ( type);
tree PPI_rhs1_cast = make_temp_ssa_name( type, NULL, "PPI_rhs1_cast");
gimple *gPPI_rhs1_cast = gimple_build_assign ( PPI_rhs1_cast, CONVERT_EXPR, rhs1);
SSA_NAME_DEF_STMT ( PPI_rhs1_cast) = gPPI_rhs1_cast;
@@ -598,12 +606,14 @@ str_reorg_instance_interleave_trans ( Info *info)
// 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", TREE_TYPE ( size));
+ gcc_assert ( 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);
// Cast arg to compatible type
+ gcc_assert( TREE_TYPE ( size));
TREE_TYPE (arg) = TREE_TYPE ( size);
tree cast_arg =
make_temp_ssa_name( TREE_TYPE ( size), NULL, "cast_arg");
@@ -668,6 +678,7 @@ str_reorg_instance_interleave_trans ( Info *info)
//tree malloc_return_type = TREE_TYPE ( arg);
//tree fail_val =
// make_temp_ssa_name ( malloc_return_type, NULL, "malloc_fail_val");
+ gcc_assert ( reorg_pointer_type);
tree fail_val =
make_temp_ssa_name ( reorg_pointer_type, NULL, "malloc_fail_val");
@@ -773,11 +784,13 @@ str_reorg_instance_interleave_trans ( Info *info)
DEBUG_F(print_generic_expr, stderr, lhs_ass_type, (dump_flags_t)0);
DEBUG("\n");
+ gcc_assert ( sizetype);
tree mem_size =
make_temp_ssa_name( sizetype, NULL, "malloc_mem_size");
// We need field_size to be of the correct type so
// we type cast.
+ gcc_assert ( TREE_TYPE ( mem_size));
tree field_size =
make_temp_ssa_name( TREE_TYPE ( mem_size), NULL, "field_size");
@@ -801,9 +814,11 @@ str_reorg_instance_interleave_trans ( Info *info)
len);
SSA_NAME_DEF_STMT ( mem_size) = gsize;
+ gcc_assert ( ptr_type_node);
tree res =
make_temp_ssa_name ( ptr_type_node, NULL, "res");
+ gcc_assert ( TREE_TYPE ( base_field));
tree cast_res =
make_temp_ssa_name ( TREE_TYPE ( base_field), NULL, "cast_res");
@@ -891,6 +906,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// code in success_bb
//
+ gcc_assert ( reorg_pointer_type);
tree success_val =
make_temp_ssa_name( reorg_pointer_type, NULL, "malloc_success_val");
@@ -935,6 +951,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// Note, BBs have a sequence of phis which create_phi_node takes care of
// adding this phi too.
+ gcc_assert ( TREE_TYPE ( success_val));
tree m_phi_val =
make_temp_ssa_name ( TREE_TYPE ( success_val), NULL, "m_phi_val");
gphi *der_phi = create_phi_node( m_phi_val, after_bb);
@@ -1006,10 +1023,12 @@ 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);
+ gcc_assert ( ptr_type_node);
tree m_cast2free =
make_temp_ssa_name( ptr_type_node, NULL, "m_cast2free");
// Tried reorg_pointer_type
+ gcc_assert ( base_field_type);
tree m_to_free =
make_temp_ssa_name( base_field_type, NULL, "malloc_to_free");
gcall *free_call = gimple_build_call( fndecl_free, 1, m_cast2free);
@@ -1241,6 +1260,18 @@ str_reorg_instance_interleave_trans ( Info *info)
case ReorgT_UserFunc:
// Needed for helloworld.
// TBD The type must be adjusted (maybe.)
+
+ // New thoughts for
+ // ... = func(...,reorg_type *x,..)
+ // Doesn't the func decl type have to be adjusted for
+ // x to be the pointer rep? Where do I do it?
+ // Here doesn't seem like a great idea.
+ // Note, do we need to emit this?
+ // x' = (pointre_rep)x
+ // ... = func(...,x',...)
+ // Look at is_user_funtion on hint on the
+ // how to get info on func.
+
// Note, what proably needed is an extra
// mini-pass to adjust all "dangling" SSA temps.
@@ -1270,6 +1301,299 @@ str_reorg_instance_interleave_trans ( Info *info)
pop_cfun ();
}
+ 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
+ // before doing anything else.
+ // TBD Call init_ssa_name_imm_use for certain
+ // ssa names.
+
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
+ {
+ struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
+ push_cfun ( func);
+
+ // We need a map of old ssa_name to new ssa_name.
+ std::map <tree,tree> ssa_map;
+
+ // Walk function decl.
+ // Modify declaractions modifies the formal parameter types.
+ // TBD That needs to be moved here
+ // Never the less we need to associate new default defs with them.
+ // At the end of find_decls_and_types adds parameter decls.
+ // We'll use get_or_create_ssa_default_def on the ssa name and
+ // create a new decl for the decls that are pointers to
+ // reorg types.
+ //
+ // Then walk the gimple looking for dangling types. When we find
+ // one on the right hand side check to see if it's on the
+ // map. If not we create a ssa name and add it to the map. We
+ // subsitute it into operand. For the left hand side we also
+ // set the statement definition.
+
+ // STUFF TO USE
+ // release_ssa_name_fn
+ // FOR_EACH_IMM_USE_STMT
+
+ // Default defs case first
+ // For parameters
+ DEBUG_L("Dangling Types for Function Params (default defs).\n");
+ INDENT(4);
+ tree parm;
+ for ( parm = DECL_ARGUMENTS ( func->decl);
+ parm;
+ parm = DECL_CHAIN ( parm) )
+ {
+ DEBUG_A("param: ");
+ DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
+ DEBUG("\n");
+ tree old_default_def = ssa_default_def ( func, parm);
+ DEBUG_A("old_default_def: ");
+ DEBUG_F( print_generic_expr, stderr, old_default_def, (dump_flags_t)0);
+ DEBUG("\n");
+ tree new_default_def;
+
+ // Modify prameter and do the default def stuff
+ // TBD The possibility exists that we'll need to create
+ // a new decl rather than modify the existing one.
+ if ( modify_decl_core ( &parm, info) )
+ {
+ //DEBUG_A("double check new param: ");
+ //DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
+ //DEBUG("\n");
+ // TBD New default def here
+
+ // If the variable of the decl is initialized
+ // then it shouldn't be associated with a default def.
+ if ( old_default_def )
+ {
+ // TBD Do we delete the old one and if so,
+ // do we do it here and how do we do it?
+
+ // Create new default def here.
+ // NOTE parm looks correct here but type of new_default_def
+ // is that of old_default_def so this might just look up
+ // old_default_def!
+ //new_default_def = get_or_create_ssa_default_def ( func, parm);
+ // ??? try this (in conjunction with the above) to fix things... NOPE
+ //set_ssa_default_def ( func, parm, new_default_def);
+ // ??? these instead
+ new_default_def = make_ssa_name_fn ( func, parm, gimple_build_nop ());
+ set_ssa_default_def ( func, parm, new_default_def);
+
+
+ DEBUG_A("new_default_def: ");
+ DEBUG_F(print_generic_expr, stderr, new_default_def, (dump_flags_t)0);
+ DEBUG(", TYPE: ");
+ DEBUG_F(print_generic_expr, stderr, TREE_TYPE(new_default_def), (dump_flags_t)0);
+ DEBUG("\n");
+
+ // Replace old one (PROBABLY DID THIS WRONG!)
+ set_ssa_default_def ( func, parm, new_default_def);
+
+ imm_use_iterator iter;
+ gimple *stmt;
+ use_operand_p use;
+ // Modify stmts using old default def to use
+ // 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;
+ ssa_op_iter ssa_iter;
+ FOR_EACH_SSA_USE_OPERAND( use_p, stmt, ssa_iter, SSA_OP_USE )
+ {
+ if ( use_p == NULL ) continue;
+ tree use = USE_FROM_PTR (use_p);
+ DEBUG_A("use to replace: ");
+ DEBUG_F( print_generic_expr, stderr, use, (dump_flags_t)0);
+ DEBUG("\n");
+ if (use == old_default_def)
+ SET_USE ( use_p, new_default_def);
+ }
+ DEBUG_A("after: ");
+ DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
+ #endif
+ }
+ }
+
+
+ }
+ }
+ INDENT(-4);
+ // TBD reverse chain here? ... Hopefully not!
+
+ DEBUG_L("Dangling Types for Function Local (default defs).\n");
+ INDENT(4);
+ // For locals
+ unsigned i;
+ tree decl;
+ FOR_EACH_LOCAL_DECL ( func, i, decl)
+ {
+ DEBUG_A("local: ");
+ DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)0);
+ DEBUG("\n");
+ tree old_default_def = ssa_default_def ( func, decl);
+ tree new_default_def;
+
+ // Modify prameter and do the default def stuff
+ // TBD The possibility exists that we'll need to create
+ // a new decl rather than modify the existing one.
+ if ( modify_decl_core ( &decl, info) )
+ {
+ // TBD New default def here
+
+ // If the variable of the decl is initialized
+ // then it shouldn't be associated with a default def.
+ if ( old_default_def )
+ {
+ // TBD Do we delete the old one and if so,
+ // do we do it here and how do we do it?
+
+ // Create new default def here.
+ new_default_def = get_or_create_ssa_default_def ( func, decl);
+
+ imm_use_iterator iter;
+ gimple *stmt;
+ use_operand_p use;
+ // Modify stmts using old default def to use
+ // new default def
+ FOR_EACH_IMM_USE_STMT ( stmt, iter, old_default_def)
+ {
+ FOR_EACH_IMM_USE_ON_STMT ( use, iter)
+ {
+ SET_USE ( use, new_default_def);
+ }
+ // Possibly do this???
+ //update_stmt ( stmt);
+ }
+ }
+ }
+ }
+ INDENT(-4);
+
+ // Normal ssa name case
+ DEBUG_L("Dangling Types for Normal SSA Names:\n");
+ INDENT(4);
+ // We use len instead of using func->length() in the for loop test
+ // because new ssa names are created in the loop body and we
+ // shouldn't process them.
+ unsigned int len = SSANAMES ( func)->length ();
+ DEBUG_L("len = %d\n",len);
+ for ( unsigned int i = 0; i < len; i++)
+ {
+ DEBUG_L("SSANAMES(func)[%d]\n",i);
+
+ tree ssa_name = (*SSANAMES ( func))[i];
+
+ if( ssa_name == NULL )
+ {
+ DEBUG_L("Skip, ssa_name == NULL\n");
+ continue;
+ }
+
+ if ( ssa_defined_default_def_p ( ssa_name))
+ {
+ DEBUG_L("Skip, ssa_name ");
+ DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
+ DEBUG(" is default_def\n");
+ continue;
+ }
+
+ tree type = TREE_TYPE ( ssa_name);
+ tree bottom_type = base_type_of ( type);
+ ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
+ DEBUG_L("ssa_name = ");
+ DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
+ DEBUG(", type = ");
+ DEBUG_F(print_generic_expr, stderr, type, (dump_flags_t)0);
+ DEBUG(", bottom_type = ");
+ DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
+ DEBUG(", ri = %p\n",ri);
+
+ // If it's not a dangling type we don't care
+ if ( ri == NULL )
+ {
+ DEBUG_L("Skip, ri == NULL\n");
+ continue;
+ }
+
+ tree new_type = ri->pointer_rep;
+ tree new_ssa_name = make_temp_ssa_name( new_type, NULL, "dedangled");
+ DEBUG_L("new_ssa_name = ");
+ DEBUG_F(print_generic_expr, stderr, new_ssa_name, (dump_flags_t)0);
+ DEBUG("\n");
+ #if DEBUGGING
+ for ( unsigned int j = 0; j < SSANAMES ( func)->length (); j++)
+ {
+ if ( (*SSANAMES ( func))[j] == new_ssa_name )
+ {
+ DEBUG_L("new name at j = %d\n",j);
+ break;
+ }
+ }
+ #endif
+
+ gimple *use_stmt;
+ imm_use_iterator iter;
+ FOR_EACH_IMM_USE_STMT ( use_stmt, iter, ssa_name)
+ {
+ // The statement should be an assign and the
+ // ssa name should be on the left hand side.
+ // This is because all other ssa names uses
+ // should have been transformed out of existence
+ // at this point in time.
+ // TBD -- put in asserts to this effect
+ DEBUG_L("use_stmt: ");
+ DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
+
+ // !!! FIX it with operand walk!
+ use_operand_p use_p;
+ ssa_op_iter ssa_iter;
+ FOR_EACH_SSA_USE_OPERAND( use_p, use_stmt, ssa_iter, SSA_OP_USE )
+ {
+ //DEBUG_L("use_p = %p\n",use_p);
+ if ( use_p == NULL ) continue;
+ tree use = USE_FROM_PTR (use_p);
+ if (use == ssa_name)
+ SET_USE ( use_p, new_ssa_name);
+ }
+ // Should update_stmt be called here?
+ // It does seem either harm or help so I'll
+ // leave it in.
+ update_stmt ( use_stmt);
+ }
+ // Modify the LHS too
+ // TBD This code needs to be more general.
+ gimple *def = SSA_NAME_DEF_STMT ( ssa_name);
+
+ DEBUG_L("def: ");
+ DEBUG_F ( print_gimple_stmt, stderr, def, 0);
+
+ if ( gimple_code ( def) != GIMPLE_ASSIGN ) continue;
+
+ gimple_assign_set_lhs ( def, new_ssa_name);
+
+ // This is where we know that ssa_name needs to be replaced
+ release_ssa_name_fn ( func, ssa_name);
+ }
+ INDENT(-4);
+
+ 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
@@ -1333,6 +1657,11 @@ str_reorg_instance_interleave_trans ( Info *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) )
@@ -1401,10 +1730,17 @@ str_reorg_instance_interleave_trans ( Info *info)
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 )
{
@@ -1417,11 +1753,23 @@ str_reorg_instance_interleave_trans ( Info *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");
// TBD Should this be a diagnostic or not?
DEBUG ("INTERNALS PRINT\n");
@@ -1430,7 +1778,7 @@ str_reorg_instance_interleave_trans ( Info *info)
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, PRINT_FORMAT, 4);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info);
}
}
@@ -1474,6 +1822,7 @@ wrangle_ssa_type( tree side, Info_t *info )
{
DEBUG_L( "LEVELS ZERO\n");
modify_ssa_name_type ( side, ri->pointer_rep);
+ DEBUG_L("after modify_ssa_name_type\n");
}
else
{
@@ -1482,7 +1831,19 @@ wrangle_ssa_type( tree side, Info_t *info )
}
}
-static bool
+void
+print_internal_op ( tree op)
+{
+ tree type = TREE_TYPE ( op);
+ print_generic_expr ( stderr, op, (dump_flags_t)0);
+ fprintf( stderr, " TYPE: ");
+ print_generic_expr ( stderr, type, (dump_flags_t)0);
+ fprintf( stderr, " MAIN_TYPE: ");
+ print_generic_expr ( stderr, TYPE_MAIN_VARIANT ( type), (dump_flags_t)0);
+ fprintf( stderr, "\n");
+}
+
+bool
print_internals (gimple *stmt, void *data)
{
Info_t *info = (Info_t*)data;
@@ -1517,13 +1878,13 @@ print_internals (gimple *stmt, void *data)
if ( rhs2 )
{
fprintf( stderr, ", RHS2%s: ", rhs2_ssa ? "*" : "");
- print_generic_expr ( stderr, TREE_TYPE ( rhs2), (dump_flags_t)0);
+ print_internal_op ( rhs2);
}
if ( rhs3 )
{
fprintf( stderr, ", RHS3%s: ", rhs3_ssa ? "*" : "");
- print_generic_expr ( stderr, TREE_TYPE ( rhs3), (dump_flags_t)0);
+ print_internal_op ( rhs3);
}
fprintf ( stderr, "\n");
} else
@@ -1535,27 +1896,33 @@ print_internals (gimple *stmt, void *data)
tree def = PHI_RESULT ( phi_stmt);
fprintf( stderr, " OP: ");
- print_generic_expr ( stderr, def, (dump_flags_t)0);
- fprintf( stderr, " TYPE: ");
- print_generic_expr ( stderr, TREE_TYPE ( def), (dump_flags_t)0);
- fprintf( stderr, "\n");
+ print_internal_op ( def);
FOR_EACH_PHI_ARG ( phi_op, phi_stmt, iter, SSA_OP_ALL_OPERANDS)
{
tree op = USE_FROM_PTR ( phi_op);
fprintf( stderr, " OP: ");
- print_generic_expr ( stderr, op, (dump_flags_t)0);
- fprintf( stderr, " TYPE: ");
- print_generic_expr ( stderr, TREE_TYPE ( op), (dump_flags_t)0);
- fprintf( stderr, "\n");
+ print_internal_op ( op);
}
}
else
{
- // This is OK I believe unless checking CONDs is necessary
- ;
+ ssa_op_iter iter;
+ tree op_def;
+ use_operand_p opu;
+ FOR_EACH_SSA_TREE_OPERAND ( op_def, stmt, iter, SSA_OP_ALL_DEFS)
+ {
+ fprintf( stderr, " DEF OP: ");
+ print_internal_op ( op_def);
+ }
+ FOR_EACH_SSA_USE_OPERAND ( opu, stmt, iter, SSA_OP_ALL_USES)
+ {
+ tree use_op = USE_FROM_PTR ( opu);
+ fprintf( stderr, " USE OP: ");
+ print_internal_op ( use_op);
+ }
}
-
+
return false;
}
@@ -1639,7 +2006,7 @@ create_a_new_type ( Info_t *info, tree type)
// and static arrays are not allowed "yet."
tree field;
tree new_fields = NULL;
- for ( field = TYPE_FIELDS ( type); // WHF, I speced reorg_type_prime here???
+ for ( field = TYPE_FIELDS ( type); // ??? I speced reorg_type_prime here???
field;
field = DECL_CHAIN ( field))
{
@@ -1686,6 +2053,7 @@ create_a_new_type ( Info_t *info, tree type)
*/
tree pointer_rep = make_signed_type ( TYPE_PRECISION ( pointer_sized_int_node));
+ TYPE_MAIN_VARIANT ( pointer_rep) = TYPE_MAIN_VARIANT ( pointer_sized_int_node);
//DEBUG("Issue with gcc_ of reorg\n");
//DEBUG_F(print_reorg, stderr, 2, ri);
const char *gcc_name =
@@ -1700,6 +2068,9 @@ create_a_new_type ( Info_t *info, tree type)
DEBUG_L("pointer_rep = ");
DEBUG_F( print_generic_expr, stderr, pointer_rep, (dump_flags_t)-1);
DEBUG("\n");
+ DEBUG_A("TYPE_MAIN_VARIANT ( pointer_rep) = ");
+ DEBUG_F( print_generic_expr, stderr, TYPE_MAIN_VARIANT ( pointer_rep), (dump_flags_t)-1);
+ DEBUG("\n");
// TBD ! Some of the key bits from above seem to be missing below.
// Specifically make_node for the base type, setting the base
@@ -1809,12 +2180,14 @@ create_a_new_type ( Info_t *info, tree type)
// The type pointed to changes for single-pool.
ReorgType_t *ri =
get_reorgtype_info ( field_type, info);
+ gcc_assert ( ri->pointer_rep);
TREE_TYPE ( field) = ri->pointer_rep;
}
tree base = base_type_of ( field);
if ( is_reorg_type ( base, info) )
{
// strip off a layer of pointers
+ gcc_assert ( TREE_TYPE ( TREE_TYPE( field)));
TREE_TYPE ( field) = TREE_TYPE ( TREE_TYPE( field));
}
}
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index 13b8749ee12..b8a89d6fe1f 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
+#include "tree-ssa.h"
#include "gimple.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
@@ -68,7 +69,7 @@ static void transformation_legality_debug ( Info *, ReorgType *);
static bool reorg_legality ( Info *);
static void reorg_common_middle_code ( Info *);
static void modify_declarations ( Info *);
-static void modify_decl_core ( tree *, Info *);
+//static void modify_decl_core ( tree *, Info *);
static void reorg_forbidden ( gimple *, Info *);
// Name changed and moved to its own file
//static void reorg_transformation ( Info *);
@@ -136,7 +137,11 @@ ipa_structure_reorg ( void)
return true;
}
+ DEBUG_L("after reorg_analysis\n");
+
bool qualified = reorg_qualification(&info);
+ DEBUG_L("after reorg_qualification\n");
+
if ( qualified )
{
if ( flag_ipa_structure_reorg || flag_ipa_dead_field_eliminate )
@@ -156,6 +161,7 @@ ipa_structure_reorg ( void)
{
//DEBUG_L("before str_reorg_instance_interleave_qual\n");
str_reorg_instance_interleave_qual ( &info);
+ DEBUG_L("after str_reorg_instance_interleave_qual\n");
}
if ( info.show_all_reorg_cands_in_detail )
@@ -165,6 +171,7 @@ ipa_structure_reorg ( void)
}
reorg_common_middle_code( &info); // ??? might not amount to anything
+ DEBUG_L("after reorg_common_middle_code\n");
if ( flag_ipa_structure_reorg || flag_ipa_dead_field_eliminate )
{
@@ -215,8 +222,8 @@ initial_debug_info ( Info *info)
{
if ( info->reorg_dump_file )
{
- print_program ( info->reorg_dump_file, PRINT_FORMAT, 0);
- }
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 0, info);
+ }
}
static void
@@ -224,8 +231,7 @@ final_debug_info ( Info *info)
{
if ( info->reorg_dump_file )
{
- print_program ( info->reorg_dump_file, PRINT_FORMAT, 0);
- wolf_fence ( info);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 0, info);
}
}
@@ -652,6 +658,7 @@ static bool find_decls_and_types ( Info *info)
{
//DEBUG_L( "function: %s\n", lang_hooks.decl_printable_name ( node->decl, 2));
//INDENT(2);
+ #if !NEW_SSA_SCHEME
// local declarations
unsigned i;
tree decl;
@@ -669,7 +676,7 @@ static bool find_decls_and_types ( Info *info)
//DEBUG_F( print_progdecl, stderr, 2, &decl_info);
}
}
-
+
// parameter declarations
//DEBUG_L( "ProgDecl parameter declarations:\n");
tree parm;
@@ -692,6 +699,7 @@ static bool find_decls_and_types ( Info *info)
//DEBUG_A(" -- Added to ProgDecls\n");
}
}
+ #endif
//INDENT(-2);
}
//INDENT(-2);
@@ -1010,18 +1018,21 @@ modify_declarations ( Info *info)
// Note, do not relayout functions decls....
}
-static void
+// TBD Reading this I don't see how it actually works
+// correctly
+// Returns true if a modification occurred
+bool
modify_decl_core ( tree *location, Info *info)
{
- //DEBUG_L("before modify_decl_core");
- //DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_L("before modify_decl_core");
+ DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0);
+ DEBUG("\n");
tree type = *location;
tree base = base_type_of ( type);
ReorgType_t *ri = get_reorgtype_info ( base, info);
if ( ri == NULL )
{
- return;
+ return false;
}
// array case -- not doing non-dynamically
@@ -1035,20 +1046,21 @@ modify_decl_core ( tree *location, Info *info)
{
prev_type = type;
type = TREE_TYPE ( prev_type);
- //DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
+ DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
}
// TBD might use build_pointer_type to build new type for *(N)reorg_type
// to *(N-1)ri->pointer_rep
// Fakes this for levels == 1
if ( levels == 0)
{
- //DEBUG_L( "LEVEL ZERO\n");
+ DEBUG_L( "LEVEL ZERO\n");
//modify_ssa_name_type ( side, ri->pointer_rep);
+ gcc_assert ( TYPE_MAIN_VARIANT ( ri->pointer_rep));
TREE_TYPE ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
}
else
{
- //DEBUG_L( "LEVEL > ZERO\n");
+ DEBUG_L( "LEVEL > ZERO\n");
gcc_assert(0);
}
@@ -1060,9 +1072,10 @@ modify_decl_core ( tree *location, Info *info)
relayout_decl ( *location);
- //DEBUG_L(" after modify_decl_core");
- //DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0);
- //DEBUG("\n");
+ DEBUG_L(" after modify_decl_core");
+ DEBUG_F( print_generic_decl, stderr, *location, (dump_flags_t)0);
+ DEBUG("\n");
+ return true;
}
void
@@ -1926,7 +1939,7 @@ print_progdecl ( FILE *file, int leading_space, ProgDecl_t *progdecl )
}
void
-print_program ( FILE *file, bool my_format, int leading_space )
+print_program ( FILE *file, bool my_format, int leading_space, Info_t *info)
{
struct cgraph_node *node;
fprintf ( file, "%*sProgram:\n", leading_space, "");
@@ -1955,6 +1968,9 @@ print_program ( FILE *file, bool my_format, int leading_space )
dump_function_to_file ( func->decl, file, (dump_flags_t)0);
}
}
+
+ DEBUG ("INTERNALS PRINT\n");
+ DEBUG_F (apply_to_all_gimple, print_internals, true, (void*)info);
}
static void
@@ -2111,17 +2127,54 @@ modify_ssa_name_type ( tree ssa_name, tree type)
// This rips off the code in make_ssa_name_fn.
// Note, this probabily be made into special function
// that is part of tree-ssanames.
- if ( TYPE_P ( type))
+ DEBUG_L("modify_ssa_name_type ssa_name ");
+ DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
+ DEBUG("\n");
+ //gcc_assert ( TREE_TYPE ( type));
+ DEBUG_A("type: ");
+ DEBUG_F(print_generic_expr, stderr, type, (dump_flags_t)0);
+ DEBUG("\n");
+ DEBUG_A("TREE_TYPE(type): ");
+ DEBUG_F(print_generic_expr, stderr, TREE_TYPE(type), (dump_flags_t)0);
+ DEBUG("\n");
+ DEBUG_A("TYPE_MAIN_VARIANT(type) :");
+ DEBUG_F(print_generic_expr, stderr, TYPE_MAIN_VARIANT(type), (dump_flags_t)0);
+ DEBUG("\n");
+ DEBUG_A("ssa_defined_default_def_p(ssa_name) %s\n",
+ ssa_defined_default_def_p(ssa_name) ? "true" : "false");
+
+ #if 0
+ // Erick's suggestion
+ TREE_TYPE ( ssa_name) = type;
+ relayout_decl ( ssa_name); // only this breaks
+ #else
+ if ( TYPE_P ( type) )
{
- //DEBUG_L("modify_ssa_name_type TYPE_P true\n");
+ DEBUG_L("TYPE_P true\n");
+ gcc_assert ( TYPE_MAIN_VARIANT ( type));
TREE_TYPE ( ssa_name) = TYPE_MAIN_VARIANT ( type);
- SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, NULL_TREE);
+ if ( ssa_defined_default_def_p ( ssa_name) )
+ {
+ // Again this is what breaks (pretty-print) something
+ // about expecting an integer_type.
+ // Our _reorg_SP_ptr_type_type_t really is an integer
+ // type but it doesn't know it.
+ SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, TYPE_MAIN_VARIANT ( type));
+ }
+ else
+ {
+ // The following breaks defaults defs hence the check above.
+ SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, NULL_TREE);
+ }
}
else
{
+ DEBUG_L("TYPE_P false\n");
+ gcc_assert ( TREE_TYPE ( type));
TREE_TYPE ( ssa_name) = TREE_TYPE ( type);
SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, type);
}
+ #endif
}
//-- debugging only --
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index 7ba69b90460..a82481fc084 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see
#define USE_REORG_TYPES 1
// If PRINT_FORMAT is true use pass specific print format.
#define PRINT_FORMAT false
+// use new ssa type modification scheme
+#define NEW_SSA_SCHEME 1
typedef struct RT_Elim RT_Elim;
typedef struct RT_Reorder RT_Reorder;
@@ -216,6 +218,7 @@ extern int str_reorg_field_reorder ( Info *);
extern int str_reorg_instance_interleave ( Info *);
#endif
+extern bool modify_decl_core ( tree *, Info *);
extern void delete_reorgtype ( ReorgType_t *, Info_t *);
extern void undelete_reorgtype ( ReorgType_t *, Info_t *);
extern void clear_deleted_types( Info *);
@@ -233,9 +236,11 @@ extern bool tree_contains_a_reorgtype_p ( tree, Info *);
extern bool is_reorg_type ( tree, Info_t *);
extern tree base_type_of ( tree);
extern void print_reorg ( FILE *, int, ReorgType_t *);
-extern void print_program ( FILE *, bool, int);
+extern void print_program ( FILE *, bool, int, Info_t *);
extern void print_type ( FILE *, tree);
extern void modify_ssa_name_type ( tree, tree);
+extern bool print_internals (gimple *, void *);
+
// I have no intention of leaving this or uses of the