summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-07-21 21:15:42 -0700
committerGary Oblock <gary@amperecomputing.com>2020-07-21 21:15:42 -0700
commit2db1c71b3de3ba589be96272d819407c34bbc487 (patch)
treefe39834ae3c5c0464e025426da7ab5c82c9bd43e
parent025957cead65df04df192761295edb3f38a2280b (diff)
Fixed two errors of omission (stub functions needed bodies.)
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c64
-rw-r--r--gcc/ipa-structure-reorg.c170
-rw-r--r--gcc/ipa-structure-reorg.h7
3 files changed, 135 insertions, 106 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index d3087f9e1f2..746b63cf9cf 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -84,7 +84,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, 4);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 4);
}
struct cgraph_node *node;
@@ -1056,7 +1056,7 @@ str_reorg_instance_interleave_trans ( Info *info)
#endif
//DEBUG_L("End of malloc:\n");
- //DEBUG_F( print_program, stderr, 4);
+ //DEBUG_F( print_program, PRINT_FORMAT, stderr, 4);
}
#endif
INDENT(-2);
@@ -1272,8 +1272,7 @@ str_reorg_instance_interleave_trans ( Info *info)
// TBD A mini-pass to fixup dangling SSA temps. We need to modidy
// function parameter too before we do that.
- // is run here.
- int mini_pass; // Passes 0 and two are just for testing
+ int mini_pass; // Passes 0 and 2 are just for testing
for ( mini_pass = 0; mini_pass < 3; mini_pass++ )
{
header ( true);
@@ -1401,57 +1400,7 @@ str_reorg_instance_interleave_trans ( Info *info)
{
if ( lhs_ssa )
{
- #if 1
wrangle_ssa_type ( lhs, info);
- #else
- 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);
- int levels;
- for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ )
- {
- prev_type = type;
- type = TREE_TYPE ( prev_type);
- DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
- }
-
- // I thought about doing this:
- // 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;
-
- // 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( "LEVELS ZERO\n");
- }
- else
- {
- if ( levels == 1 )
- {
- TREE_TYPE ( lhs) = ri->pointer_rep;
- }
- else
- {
- gcc_assert(0);
- }
- }
- #endif
}
if ( rhs1_ssa )
{
@@ -1474,13 +1423,14 @@ str_reorg_instance_interleave_trans ( Info *info)
}
}
- fprintf ( stderr, "INTERNALS PRINT\n");
- apply_to_all_gimple ( print_internals, true, (void *)info);
+ // TBD Should this be a diagnostic or not?
+ DEBUG ("INTERNALS PRINT\n");
+ DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)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, 4);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 4);
}
}
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index 80b0acb4c83..46501b090eb 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -25,28 +25,29 @@ along with GCC; see the file COPYING3. If not see
#include "backend.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
+#include "gimple-collector.hpp"
+#include "gimple-escaper.hpp"
#include "tree-pass.h"
+#include "tree-cfg.h"
#include "cgraph.h"
-#include "gimple-iterator.h"
-#include "pretty-print.h"
-#include <vector>
-#include <map>
-#include <set>
-#include "ipa-structure-reorg.h"
#include "dumpfile.h"
#include "pretty-print.h"
#include "tree-pretty-print.h"
#include "gimple-pretty-print.h"
#include "langhooks.h"
-#include "gimple-walk.h"
-// TBD more includes go here
-#include "gimple-collector.hpp"
-#include "gimple-escaper.hpp"
#include "collect-types.h"
#include "stor-layout.h"
+#include "tree-dfa.h"
+#include <vector>
+#include <map>
+#include <set>
+#include "ipa-structure-reorg.h"
static void setup_debug_flags ( Info *);
+static void initial_debug_info ( Info *);
static void final_debug_info ( Info *);
static unsigned int reorg_analysis ( Info *);
static void reorg_analysis_debug ( Info *, ReorgType *);
@@ -90,7 +91,7 @@ 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 *);
-//static void print_program ( FILE *, int);
+//static void print_program ( FILE *, bool, int);
static void print_function ( FILE *, int, function *);
static ReorgType_t *get_reorgtype( gimple *stmt, Info *, int);
static int num_reorgtypes( gimple *, Info *);
@@ -125,8 +126,10 @@ ipa_structure_reorg ( void)
// to initialize?
// Also, all functions should be references and not pointers...
Info info(&Reorg_Type, &Saved_Reorg_Type, &Prog_Decl, &StructTypes);
+ //DEBUG_L("At init dum_deleted %d\n",info.num_deleted);
setup_debug_flags ( &info);
+ //initial_debug_info ( &info);
if ( !reorg_analysis ( &info) )
{
@@ -208,12 +211,21 @@ setup_debug_flags ( Info *info)
}
static void
+initial_debug_info ( Info *info)
+{
+ if ( info->reorg_dump_file )
+ {
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 0);
+ }
+}
+
+static void
final_debug_info ( Info *info)
{
- // TBD
if ( info->reorg_dump_file )
{
- print_program ( info->reorg_dump_file, 0);
+ print_program ( info->reorg_dump_file, PRINT_FORMAT, 0);
+ //wolf_fence ( info);
}
}
@@ -343,6 +355,7 @@ reorg_analysis ( Info *info)
}
//INDENT(-2);
+ //DEBUG_L("after reorg_analysis\n");
remove_deleted_types ( info, &reorg_analysis_debug);
if ( info->show_all_reorg_cands )
@@ -429,10 +442,10 @@ static bool find_decls_and_types ( Info *info)
struct function *fn = DECL_STRUCT_FUNCTION ( node->decl);
// enable this to see error in test_1_8. Note, not a bug...
- DEBUG_L( " function name = %s\n", lang_hooks.decl_printable_name ( node->decl, 2));
+ //DEBUG_L( " function name = %s\n", lang_hooks.decl_printable_name ( node->decl, 2));
if ( fn == NULL )
{
- DEBUG_L( " EMPTY\n");
+ //DEBUG_L( " EMPTY\n");
continue;
}
@@ -459,7 +472,7 @@ static bool find_decls_and_types ( Info *info)
typeset.insert ( base); // ???
}
}
- //INDENT(-2)
+ //INDENT(-2);
}
// We need this later for creating new types
@@ -584,7 +597,7 @@ static bool find_decls_and_types ( Info *info)
//INDENT(-2);
}
//INDENT(-2);
-
+ //DEBUG_L( "after Scan all types in ReorgTypes for structure fields\n");
remove_deleted_types ( info, &initial_reorg_debug);
// Disqualifying structures in interior to structures is optional
@@ -706,6 +719,9 @@ add_reorg_type ( tree base, Info *info)
{ 0, true, base, NULL, NULL, false, false, false,
{ 0}, { 0}, { 0, 0, 0, NULL, 0.0, 0.0, false}};
+ //DEBUG_L("add_reorg_type: ");
+ //DEBUG_F(print_generic_expr, base, (dump_flags_t)0);
+ //DEBUG("\n");
info->reorg_type->push_back ( rt);
// Remember the intial assumption is the type added will be deleted
// and is marked to be deleted.
@@ -773,7 +789,7 @@ disqualify_struct_in_struct_or_union ( Info *info)
}
//INDENT(-2);
}
-
+ //DEBUG_L("after disqualify_struct_in_struct_or_union\n");
remove_deleted_types ( info,
&disqualify_struct_in_struct_or_union_debug);
}
@@ -928,6 +944,8 @@ transformation_legality ( Info *info)
{
if ( reorg_recognize( stmt, node, info) == Not_Supported )
{
+ DEBUG_L("deleting %d reorgs for unsuported stmt: ", num);
+ DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
int i;
for ( i = 0; i < num; i++ )
{
@@ -946,6 +964,7 @@ transformation_legality ( Info *info)
}
}
+ //DEBUG_L("after transformation_legality\n");
remove_deleted_types ( info, &transformation_legality_debug);
return !info->reorg_type->empty ();
@@ -994,9 +1013,9 @@ modify_declarations ( Info *info)
static void
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);
@@ -1016,20 +1035,20 @@ 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);
TREE_TYPE ( *location) = TYPE_MAIN_VARIANT ( ri->pointer_rep);
}
else
{
- DEBUG_L( "LEVEL > ZERO\n");
+ //DEBUG_L( "LEVEL > ZERO\n");
gcc_assert(0);
}
@@ -1041,36 +1060,36 @@ 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");
}
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");
}
}
void
undelete_reorgtype ( ReorgType_t *rt, Info *info )
{
- //DEBUG_L( "undelete_reorgtype( %s ): ", type_name_to_str( TYPE_NAME( rt->gcc_type)));
+ DEBUG_L( "undelete_reorgtype( %s ): ", type_name_to_str( TYPE_NAME( rt->gcc_type)));
if ( rt->delete_me )
{
- //DEBUG( "UNDELETE\n");
+ DEBUG( "UNDELETE\n");
info->num_deleted--;
rt->delete_me = false;
} else {
- //DEBUG( "SKIP\n");
+ DEBUG( "SKIP\n");
}
}
@@ -1850,10 +1869,10 @@ print_base_reorg ( FILE *file, int leading_space, ReorgType_t *reorg, bool detai
field = DECL_CHAIN( field))
{
fprintf ( file, "%*s", leading_space + 4, "");
- print_generic_expr ( stderr, field, (dump_flags_t)0);
+ print_generic_expr ( file, field, (dump_flags_t)0);
fprintf ( stderr, ": ");
- print_generic_expr ( stderr, TREE_TYPE ( field), (dump_flags_t)0);
- fprintf ( stderr, "\n");
+ print_generic_expr ( file, TREE_TYPE ( field), (dump_flags_t)0);
+ fprintf ( file, "\n");
}
}
}
@@ -1907,7 +1926,7 @@ print_progdecl ( FILE *file, int leading_space, ProgDecl_t *progdecl )
}
void
-print_program ( FILE *file, int leading_space )
+print_program ( FILE *file, bool my_format, int leading_space )
{
struct cgraph_node *node;
fprintf ( file, "%*sProgram:\n", leading_space, "");
@@ -1926,11 +1945,15 @@ print_program ( FILE *file, int leading_space )
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
{
struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
- #if 0
- // print func name
- fprintf ( file, "%*sFunc: %s\n", leading_space + 2, "", lang_hooks.decl_printable_name ( node->decl, 2));
- #endif
- print_function ( file, leading_space + 4, func);
+ if ( my_format )
+ {
+ print_function ( file, leading_space + 4, func);
+ }
+ else
+ {
+ dump_function_header ( file, func->decl, (dump_flags_t)0);
+ dump_function_to_file ( func->decl, file, (dump_flags_t)0);
+ }
}
}
@@ -2019,15 +2042,50 @@ print_function ( FILE *file, int leading_space, struct function *func)
ReorgType_t *
get_reorgtype( gimple *stmt, Info *info, int i)
{
- // TBD - Straight forward
- NULL;
+ // Looking at operands of statement, when we get to
+ // the ith one, return it.
+ int num_reorgs = 0;
+ unsigned num_ops = gimple_num_ops ( stmt);
+ unsigned j;
+ for ( j = 0; j < num_ops; j++ )
+ {
+ tree op = gimple_op ( stmt, j);
+ if ( tree_contains_a_reorgtype_p ( op, info) ) {
+ num_reorgs++;
+ if ( num_reorgs == i )
+ {
+ return get_reorgtype_info ( op, info);
+ }
+ }
+ }
+ gcc_assert ( 0);
}
int
num_reorgtypes( gimple *stmt, Info *info)
{
- // TBD - Straight forward
- 0;
+ //DEBUG_L("num_reorgtypes: ");
+ //DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
+ // Looking at operands of statement, count
+ // the number that have reorg types.
+ // Note, they may be (most likely are) the same as other
+ // reorg types in the statement.
+ int num_reorgs = 0;
+ unsigned num_ops = gimple_num_ops ( stmt);
+ unsigned i;
+ for ( i = 0; i < num_ops; i++ )
+ {
+ tree op = gimple_op ( stmt, i);
+ //DEBUG_A("op%d: ",i);
+ //DEBUG_F( print_generic_expr, stderr, op, (dump_flags_t)-1);
+ if ( tree_contains_a_reorgtype_p ( op, info) )
+ {
+ num_reorgs++;
+ //DEBUG(" reorg");
+ }
+ //DEBUG( "\n");
+ }
+ return num_reorgs;
}
void
@@ -2042,6 +2100,8 @@ bool
uses_field_of_reorgtypes( gimple *stmt, Info * info)
{
// TBD
+ // This is a bit more sophisticated than needed
+ // for "hello world" so I'll defer this for a bit.
return false;
}
@@ -2053,6 +2113,7 @@ modify_ssa_name_type ( tree ssa_name, tree type)
// that is part of tree-ssanames.
if ( TYPE_P ( type))
{
+ //DEBUG_L("modify_ssa_name_type TYPE_P true\n");
TREE_TYPE ( ssa_name) = TYPE_MAIN_VARIANT ( type);
SET_SSA_NAME_VAR_OR_IDENTIFIER ( ssa_name, NULL_TREE);
}
@@ -2131,6 +2192,23 @@ handle_debug_indenting ( int amount )
}
#endif
+#if DEBUGGING
+// This is whatever it needs to be whenever it needss to be it.
+// Note, dump_dfa_stats doesn't cause a failure!!!!!
+void
+wolf_fence ( Info *info)
+{
+ struct cgraph_node *node;
+ fprintf( stderr, "Wolf Fence: Attempting segfault by dumping dfa stats\n");
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) {
+ struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
+ push_cfun ( func);
+ dump_dfa_stats ( stderr);
+ pop_cfun ();
+ }
+}
+#endif
+
//---------------- Pass Control Follows ----------------
const pass_data pass_data_ipa_structure_reorg =
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index af4219c15b2..7ba69b90460 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3. If not see
// Erick this is when you do something that really steps on some toes
#define KLUDGE 1
#define USE_REORG_TYPES 1
+// If PRINT_FORMAT is true use pass specific print format.
+#define PRINT_FORMAT false
typedef struct RT_Elim RT_Elim;
typedef struct RT_Reorder RT_Reorder;
@@ -231,12 +233,10 @@ 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 *, int);
+extern void print_program ( FILE *, bool, int);
extern void print_type ( FILE *, tree);
extern void modify_ssa_name_type ( tree, tree);
-
-//#define MAX(a,b) ((a) > (b) ? (a) : (b))
// I have no intention of leaving this or uses of the
// defined marcos in the code. However, some of uses
@@ -247,6 +247,7 @@ extern void modify_ssa_name_type ( tree, tree);
extern int debug_indenting;
extern void handle_debug_indenting( int);
extern const char *code_str( enum tree_code);
+extern void wolf_fence( Info *);
// Line numbered
#define DEBUG_L(...) { fprintf( stderr, "L# %4d: %*s", __LINE__, debug_indenting, ""); fprintf( stderr, __VA_ARGS__); }