summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oblock <gary@amperecomputing.com>2020-08-11 22:03:28 -0700
committerGary Oblock <gary@amperecomputing.com>2020-08-11 22:03:28 -0700
commit0a944b8d2e0981127d0ee3f0db85000a804dcad0 (patch)
tree6fd982b17d394b09f08e955f712d5246a9f748cf
parentff6d2caf8bbbe5d7fb931aa55db406557a956e4a (diff)
Final bug fixes to get hello world working.
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c76
1 files changed, 68 insertions, 8 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index b205c2670ae..db5d323a8cf 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -57,6 +57,8 @@ static void create_new_types ( Info_t *);
static void create_a_new_type ( Info_t *, tree);
static unsigned int reorg_perf_qual ( Info *);
static tree find_coresponding_field ( tree, tree);
+static void remove_default_def ( tree, struct function *);
+
// These are local to this file by design
#define REORG_SP_PTR_PREFIX "_reorg_SP_ptr_type_"
@@ -66,6 +68,8 @@ static tree find_coresponding_field ( tree, tree);
// We use labels and gotos. This is incorrect but
// for now it better shows the structure of the code emitted.
#define USE_LABELS 0
+
+#define USE_BUILT_IN_FREE 1
int
str_reorg_instance_interleave_qual ( Info *info)
@@ -576,13 +580,19 @@ str_reorg_instance_interleave_trans ( Info *info)
//DEBUG_L("param_type_list: ");
//DEBUG_F(print_generic_expr, stderr, param_type_list, (dump_flags_t)0);
//DEBUG("\n");
+ #if !USE_BUILT_IN_FREE
tree free_return_type = void_type_node;
+ #endif
//DEBUG_L("free_return_type: ");
//DEBUG_F(print_generic_expr, stderr, free_return_type, (dump_flags_t)0);
//DEBUG("\n")
+ #if USE_BUILT_IN_FREE
+ tree fndecl_free = builtin_decl_implicit ( BUILT_IN_FREE);
+ #else
tree fntype = build_function_type ( free_return_type, param_type_list);
tree fnname = get_identifier ( "free");
tree fndecl_free = build_decl ( input_location, FUNCTION_DECL, fnname, fntype);
+ #endif
// Note, add it to the call graph at each call site
// Note, unlike other simpler transformations,
@@ -703,12 +713,21 @@ str_reorg_instance_interleave_trans ( Info *info)
tree new_ok_field_L;
// FROM (for fields) {
+ bool first = true;
for( field = TYPE_FIELDS( reorg_type);
field;
field = DECL_CHAIN( field))
{
basic_block new_bb = create_empty_bb ( prev_order);
new_bb->count = prev_order->count;
+ // Nope! Don't do this.
+ //set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb);
+ //if ( first )
+ // {
+ // first = false;
+ // set_immediate_dominator ( CDI_DOMINATORS, failure_bb, new_bb);
+ // set_immediate_dominator ( CDI_DOMINATORS, after_bb, new_bb);
+ // }
tree base_field =
find_coresponding_field ( base, field);
@@ -737,7 +756,7 @@ str_reorg_instance_interleave_trans ( Info *info)
ok_edge->count () = prev_bb->count;
add_bb_to_loop ( new_bb, before_bb->loop_father);
- // TBD what happens if I punt on this????
+ // Don't mess with the dominators.
//set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb);
// create edge and set edge probability and flags
@@ -891,10 +910,9 @@ str_reorg_instance_interleave_trans ( Info *info)
basic_block success_bb = create_empty_bb ( prev_bb);
success_bb->count = prev_bb->count;
- // FROM set imm dom success_bb as prev_bb
- // TBD let's punt of the dominators for a bit
- //set_immediate_dominator ( CDI_DOMINATORS, success_bb, prev_bb);
- // TBD set edge probability and flags
+ // NOTE, it seems I shouldn't be attempting
+ // to diddle the dominator information on the fly.
+ // set_immediate_dominator ( CDI_DOMINATORS, success_bb, prev_bb);
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);
@@ -1427,6 +1445,9 @@ str_reorg_instance_interleave_trans ( Info *info)
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);
}
@@ -1991,6 +2012,9 @@ 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)
{
@@ -2025,9 +2049,16 @@ create_a_new_type ( Info_t *info, tree type)
// "Create a new variant of TYPE, equivalent but distinct."
// Now before we panic le'ts give it a try.
//
+ #if FROM_HOOKS
+ 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);
+ DEBUG("\n");
/* Multi-pool only
// Create pointer_rep
@@ -2089,11 +2120,18 @@ create_a_new_type ( Info_t *info, tree type)
strcpy ( rec_name, REORG_SP_PREFIX);
strcat ( rec_name, base_type_name);
+ DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
+
// Build the new pointer type fields
TYPE_NAME ( reorg_type_prime) = get_identifier ( rec_name);
tree field;
tree new_fields = NULL;
- for ( field = TYPE_FIELDS ( reorg_type_prime);
+ for (
+ #if FROM_HOOKS
+ field = TYPE_FIELDS ( type);
+ #else
+ field = TYPE_FIELDS ( reorg_type_prime);
+ #endif
field;
field = DECL_CHAIN ( field))
{
@@ -2103,6 +2141,8 @@ create_a_new_type ( Info_t *info, tree type)
tree new_decl =
build_decl ( DECL_SOURCE_LOCATION (field),
FIELD_DECL, DECL_NAME (field), new_fld_type);
+ DECL_CONTEXT ( new_decl) = reorg_type_prime;
+ layout_decl ( new_decl, 0);
// Missing a bunch of attributes (see tree-nested.c:899)
// Let us seee what happens without them!
DECL_CHAIN ( new_decl) = new_fields; // <- bug: need decl, not type
@@ -2111,9 +2151,10 @@ create_a_new_type ( Info_t *info, tree type)
//DEBUG_F( print_generic_decl, stderr, new_decl, TDF_DETAILS);
//DEBUG( "\n");
}
- TYPE_FIELDS ( reorg_type_prime) = new_fields; // fix?
+
+ DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
- // store reversed fields back into reorg_type_prime
+ // store reversed fields into reorg_type_prime
TYPE_FIELDS ( reorg_type_prime) = NULL;
tree next_fld;
for ( field = new_fields;
@@ -2124,6 +2165,7 @@ create_a_new_type ( Info_t *info, tree type)
DECL_CHAIN ( field) = TYPE_FIELDS ( reorg_type_prime);
TYPE_FIELDS ( reorg_type_prime) = field;
}
+ DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
// Fix-up the layout
layout_type ( reorg_type_prime);
@@ -2132,6 +2174,7 @@ create_a_new_type ( Info_t *info, tree type)
// pool case only.
tree base_var =
build_decl ( UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, ri->reorg_ver_type);
+ // We don't want to manually set DECL_INITIAL here!
const char *type_name =
identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( ri->gcc_type)));
@@ -2150,6 +2193,8 @@ create_a_new_type ( Info_t *info, tree type)
SET_DECL_ALIGN ( base_var, TYPE_ALIGN ( ri->reorg_ver_type));
varpool_node::finalize_decl ( base_var);
+
+ relayout_decl ( base_var);
ri->instance_interleave.base = base_var;
}
@@ -2220,3 +2265,18 @@ find_coresponding_field ( tree base_decl, tree field)
}
internal_error ( "find_coresponding_field: found no field");
}
+
+static void
+remove_default_def ( tree default_def, struct function *func)
+{
+ size_t i;
+ tree ssa_name;
+ FOR_EACH_SSA_NAME ( i, ssa_name, func)
+ {
+ if ( default_def == ssa_name )
+ {
+ SSANAMES ( func)->unordered_remove ( i);
+ return;
+ }
+ }
+}