diff options
author | Gary Oblock <gary@amperecomputing.com> | 2021-01-05 12:26:25 -0800 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2021-01-05 12:26:25 -0800 |
commit | c35d4029f26f77f405bdb6e6af7a053ac825b31f (patch) | |
tree | 918364cff87c7fd86f0ea21bb10892297a37b849 | |
parent | 8cd7280db237ff06b45de75f6401ce6278c9da14 (diff) |
Fixed a bug in find_and_create_all_modified_types. The
rec_types_work_list has redundant entries and if they
are not skipped, it causes the field layout information
to be lost.
-rw-r--r-- | gcc/ipa-structure-reorg.c | 39 | ||||
-rw-r--r-- | gcc/ipa-structure-reorg.h | 3 |
2 files changed, 30 insertions, 12 deletions
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 439145a75b0..6674457ad4f 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -1294,6 +1294,9 @@ find_and_create_all_modified_types ( Info_t *info) // Build the new pointer type fields TYPE_NAME ( modified_type) = get_identifier ( rec_name); + + // Make sure this is does (this might be unnecessary) + TYPE_FIELDS (modified_type) = NULL; } //DEBUG_A("Before field creation:\n"); //DEBUG_F( dump_modified_types, stderr, false, info); @@ -1305,8 +1308,12 @@ find_and_create_all_modified_types ( Info_t *info) { tree type = rec_types_work_list.front (); rec_types_work_list.pop_front (); - //DEBUG_A("type (rec_types_work_list.front) = "); - //DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0); + DEBUG_A("type (rec_types_work_list.front) = "); + DEBUG_F(flexible_print, stderr, type, 1, (dump_flags_t)0); + + // Already processed, skip. + if ( TYPE_FIELDS ( type) != NULL ) continue; + //auto pairi = info->modified_types->find (type); auto peari = find_in_vec_of_two_types ( info->modified_types, type); //gcc_assert( peari != info->modified_types->end ()); @@ -1432,11 +1439,18 @@ find_and_create_all_modified_types ( Info_t *info) //TYPE_ARTIFICIAL ( modified_type) = 1; // ??? + //use_dump_record = true; // enables my debugging code added to layout_type layout_type ( modified_type); + //use_dump_record = false; #endif + //DEBUG_LA("modified_type (right after layout) = \n"); + //DEBUG_F( dump_record, stderr, modified_type, true); + TypeHolder *holder = &(types->find ( sane_type)->second); // Add new types to the work list if possible + // Note, this code is adding types to the work list too + // agressively and multiple entries are the result. for ( auto refingi = holder->refed_types.begin (); refingi != holder->refed_types.end (); refingi++ ) @@ -1478,11 +1492,14 @@ find_in_type_vec ( std::vector<tree> *types, tree type) return types->end (); } +bool use_dump_record = false; + void -dump_record (FILE *file, tree record_type, bool extra_details, Info_t *info) +dump_record (FILE *file, tree record_type, bool extra_details) { - //DEBUG_A("dump_record:>\n"); + fprintf ( stderr, "dump_record:>\n"); tree field; + fprintf ( file, " %p, ", record_type); flexible_print ( file, record_type, 1, (dump_flags_t)0); for ( field = TYPE_FIELDS ( record_type); field; field = DECL_CHAIN ( field)) @@ -1495,12 +1512,14 @@ dump_record (FILE *file, tree record_type, bool extra_details, Info_t *info) if ( off ) { fprintf ( file, " "); - flexible_print ( file, off, 1, (dump_flags_t)0); + flexible_print ( file, off, 0, (dump_flags_t)0); } else { - fprintf ( file, " (nil)\n"); + fprintf ( file, " (nil)"); } + fprintf ( file, ", %p", &DECL_FIELD_OFFSET ( field)); + fprintf ( file, "\n"); } } } @@ -1509,7 +1528,7 @@ static void dump_modified_types (FILE *file, bool extra_details, Info_t *info) { //DEBUG_A(""); - fprintf ( file, "dump_modified_types:%s\n", + fprintf ( file, "dump_modified_types:> %s\n", info->modified_types->begin () == info->modified_types->end () ? " (empty)" : ""); for ( auto modifi = info->modified_types->begin (); @@ -1519,9 +1538,8 @@ dump_modified_types (FILE *file, bool extra_details, Info_t *info) tree orig_type = modifi->first; tree new_type = modifi->second; //DEBUG_A(""); - fprintf ( file, " %p, ", TYPE_FIELDS ( orig_type)); #if 1 - dump_record (file, orig_type, extra_details, info); + dump_record (file, orig_type, extra_details); #else flexible_print ( file, orig_type, 1, (dump_flags_t)0); for ( field = TYPE_FIELDS ( orig_type); @@ -1546,9 +1564,8 @@ dump_modified_types (FILE *file, bool extra_details, Info_t *info) } #endif //DEBUG_A(""); - fprintf ( file, " %p, ", TYPE_FIELDS ( new_type)); #if 1 - dump_record (file, new_type, extra_details, info); + dump_record (file, new_type, extra_details); #else flexible_print ( file, new_type, 1, (dump_flags_t)0); for ( field = TYPE_FIELDS ( new_type); diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h index c421f32cfee..ef12d4f8c25 100644 --- a/gcc/ipa-structure-reorg.h +++ b/gcc/ipa-structure-reorg.h @@ -262,6 +262,7 @@ extern int str_reorg_instance_interleave ( Info *); extern void find_and_create_all_modified_types ( Info_t *); extern std::vector<two_trees_t>::iterator find_in_vec_of_two_types ( std::vector<two_trees_t> *, tree); extern std::vector<two_trees_t>::iterator find_in_vec_of_two_types_2nd ( std::vector<two_trees_t> *, tree); +extern void dump_record (FILE *, tree, bool); extern tree find_modified ( tree, #if ALLOW_REVERSE bool, @@ -312,7 +313,7 @@ extern const char *optrans_to_str ( enum ReorgOpTrans); extern char *reorgtrans_to_str ( enum ReorgTransformation); extern bool is_assign_from_ssa ( gimple *); - +//extern bool use_dump_record; // To use for a debugging hack // I have no intention of leaving these debugging marcos or uses of // them in the code. However, some of the uses should obviously be |