summaryrefslogtreecommitdiff
path: root/gcc/alias.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-01-14 08:43:32 +0100
committerRichard Biener <rguenther@suse.de>2020-01-14 09:47:02 +0100
commit6b8df3e421b56bb7853a158b889f5e45611fd31f (patch)
tree33bf50001d0dfc546744ed2fdd0962089a017631 /gcc/alias.c
parentb38e86ddb7a9b6d7e87d7cc0b23983d027fcbd96 (diff)
PR middle-end/93246 - missing alias subsets
Starting with the introduction of TYPE_TYPELESS_STORAGE the situation of having a alias-set zero aggregate field became more common which prevents recording alias-sets of fields of said aggregate as subset of the outer aggregate. component_uses_parent_alias_set_from in the past fended off some of the issues with that but the alias oracles use of the alias set of the base of an access path never appropriately handled it. The following makes it so that alias-sets of fields of alias-set zero aggregate fields are still recorded as subset of the container. 2020-01-14 Richard Biener <rguenther@suse.de> PR middle-end/93246 * alias.c (record_component_aliases): Take superset to record into, recurse for alias-set zero fields. (record_component_aliases): New oveerload wrapping around the above. * g++.dg/torture/pr93246.C: New testcase.
Diffstat (limited to 'gcc/alias.c')
-rw-r--r--gcc/alias.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/alias.c b/gcc/alias.c
index 336af4e52a7..9629b5a9f48 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -1191,15 +1191,14 @@ record_alias_subset (alias_set_type superset, alias_set_type subset)
}
}
-/* Record that component types of TYPE, if any, are part of that type for
+/* Record that component types of TYPE, if any, are part of SUPERSET for
aliasing purposes. For record types, we only record component types
for fields that are not marked non-addressable. For array types, we
only record the component type if it is not marked non-aliased. */
void
-record_component_aliases (tree type)
+record_component_aliases (tree type, alias_set_type superset)
{
- alias_set_type superset = get_alias_set (type);
tree field;
if (superset == 0)
@@ -1253,7 +1252,21 @@ record_component_aliases (tree type)
== get_alias_set (TREE_TYPE (field)));
}
- record_alias_subset (superset, get_alias_set (t));
+ alias_set_type set = get_alias_set (t);
+ record_alias_subset (superset, set);
+ /* If the field has alias-set zero make sure to still record
+ any componets of it. This makes sure that for
+ struct A {
+ struct B {
+ int i;
+ char c[4];
+ } b;
+ };
+ in C++ even though 'B' has alias-set zero because
+ TYPE_TYPELESS_STORAGE is set, 'A' has the alias-set of
+ 'int' as subset. */
+ if (set == 0)
+ record_component_aliases (t, superset);
}
}
break;
@@ -1270,6 +1283,19 @@ record_component_aliases (tree type)
}
}
+/* Record that component types of TYPE, if any, are part of that type for
+ aliasing purposes. For record types, we only record component types
+ for fields that are not marked non-addressable. For array types, we
+ only record the component type if it is not marked non-aliased. */
+
+void
+record_component_aliases (tree type)
+{
+ alias_set_type superset = get_alias_set (type);
+ record_component_aliases (type, superset);
+}
+
+
/* Allocate an alias set for use in storing and reading from the varargs
spill area. */