summaryrefslogtreecommitdiff
path: root/gcc/type-reconstructor.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/type-reconstructor.c')
-rw-r--r--gcc/type-reconstructor.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/gcc/type-reconstructor.c b/gcc/type-reconstructor.c
index 769733d33b5..bcde1890638 100644
--- a/gcc/type-reconstructor.c
+++ b/gcc/type-reconstructor.c
@@ -40,6 +40,7 @@ TypeReconstructor::set_is_not_modified_yet(const_tree t)
gcc_assert(t);
const bool is_in_reorg_map = _reorg_map.find(t) != _reorg_map.end();
modified_map[t] = false;
+ if (is_in_reorg_map) mark_all_pointing_here_as_modified();
const_tree tt = TREE_TYPE(t);
if (!tt) return;
@@ -82,7 +83,7 @@ bool
TypeReconstructor::is_memoized(const_tree t)
{
const bool already_changed = _reorg_map.find(t) != _reorg_map.end();
- //mark_all_pointing_here_as_modified();
+ mark_all_pointing_here_as_modified();
return already_changed;
}
@@ -122,6 +123,14 @@ TypeReconstructor::_walk_ARRAY_TYPE_pre(const_tree t)
set_is_not_modified_yet(t);
tree copy = build_variant_type_copy((tree) t);
+ tree domain = TYPE_DOMAIN(t);
+ if (domain) {
+ tree copy_domain = copy_node(domain);
+ tree min = TYPE_MIN_VALUE(domain);
+ tree max = TYPE_MAX_VALUE(domain);
+ TYPE_MIN_VALUE(copy_domain) = copy_node(min);
+ TYPE_MAX_VALUE(copy_domain) = copy_node(max);
+ }
in_progress.push(copy);
}
@@ -137,11 +146,23 @@ TypeReconstructor::_walk_ARRAY_TYPE_post(const_tree t)
bool is_modified = get_is_modified(t);
+ TREE_TYPE(copy) = build_variant_type_copy(TREE_TYPE(copy));
copy = is_modified ? build_distinct_type_copy(copy) : copy;
TREE_TYPE(copy) = is_modified ? _reorg_map[TREE_TYPE(t)] : TREE_TYPE(copy);
TYPE_NAME(copy) = is_modified ? get_new_identifier(copy) : TYPE_NAME(copy);
// This is useful so that we go again through type layout
TYPE_SIZE(copy) = is_modified ? NULL : TYPE_SIZE(copy);
+ tree domain = TYPE_DOMAIN(t);
+ if (domain) {
+ tree copy_domain = copy_node(domain);
+ tree min = TYPE_MIN_VALUE(domain);
+ tree max = TYPE_MAX_VALUE(domain);
+ TYPE_MIN_VALUE(copy_domain) = copy_node(min);
+ TYPE_MAX_VALUE(copy_domain) = copy_node(max);
+ }
+ TypeStringifier stringifier;
+ //std::string name = stringifier.stringify(copy);
+ log("are we going to crash is modified %s %s\n", is_modified ? "t" : "f", TypeStringifier::get_type_identifier(t));
if (is_modified) layout_type(copy);
_reorg_map[t] = is_modified ? copy : (tree)t;
@@ -253,21 +274,35 @@ TypeReconstructor::_walk_RECORD_TYPE_post(const_tree t)
tree main_reorg = _reorg_map[main];
TypeStringifier stringifier;
std::string main_s = stringifier.stringify(main_reorg);
+ log("is modified %s main variant reorged build variant type %s\n", is_modified ? "T" : "F", main_s.c_str());
tree copy_variant = build_variant_type_copy(main_reorg);
TYPE_NAME(copy_variant) = get_new_identifier(copy);
- //TYPE_SIZE(copy_variant) = NULL;
- //layout_type(copy_variant);
+ TYPE_SIZE(copy_variant) = NULL;
+ TYPE_MAIN_VARIANT(copy_variant) = main_reorg;
+ layout_type(copy_variant);
_reorg_map[t] = copy_variant;
- return;
- }
+ } else {
// Ok, so now that we have fixed the TYPE_FIELDS of the copy...
// We need to call layout_type
- copy = is_modified ? build_distinct_type_copy(copy) : copy;
- TYPE_NAME(copy) = is_modified ? get_new_identifier(copy) : TYPE_NAME(copy);
- // This is useful so that we go again through type layout
- TYPE_SIZE(copy) = is_modified ? NULL : TYPE_SIZE(copy);
- if (is_modified) layout_type(copy);
- _reorg_map[t] = is_modified ? copy : (tree)t;
+ copy = is_modified ? build_distinct_type_copy(copy) : copy;
+ TYPE_NAME(copy) = is_modified ? get_new_identifier(copy) : TYPE_NAME(copy);
+ // This is useful so that we go again through type layout
+ TYPE_SIZE(copy) = is_modified ? NULL : TYPE_SIZE(copy);
+ TYPE_MAIN_VARIANT(copy) = is_modified ? copy : TYPE_MAIN_VARIANT(copy);
+ tree main_variant = TYPE_MAIN_VARIANT(copy);
+ TypeStringifier stringifier;
+ std::string main_s = stringifier.stringify(main_variant);
+ log("main variant reorged build distinct %s\n", main_s.c_str());
+ if (is_modified) layout_type(copy);
+ _reorg_map[t] = is_modified ? copy : (tree)t;
+ }
+
+ tree record = _reorg_map[t];
+ for (tree field = TYPE_FIELDS(record); field; field = DECL_CHAIN(field))
+ {
+ relayout_decl(field);
+ }
+
}
void