aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2020-06-15 19:42:11 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2020-06-15 19:54:01 +0200
commitfb149ebdfee8995ed091f17cd64355ff54e9fb30 (patch)
tree4e4998067c3c8211f0e44cc3138318e98ad4bcdb /gcc/tree-sra.c
parentb6ab9ecd550227684643b41e9e33a4d3466724d8 (diff)
downloadgcc-fb149ebdfee8995ed091f17cd64355ff54e9fb30.zip
gcc-fb149ebdfee8995ed091f17cd64355ff54e9fb30.tar.gz
gcc-fb149ebdfee8995ed091f17cd64355ff54e9fb30.tar.bz2
Fix ICE in verify_sra_access_forest
This fixes an issue with reverse storage order in SRA, which is caught by the built-in verifier in verify_sra_access_forest. The problem is that propagate_subaccesses_from_rhs changes the type of an access from aggregate to scalar and, as discussed elsewhere, this must be done with extra care in the presence of reverse storage order. gcc/ChangeLog * tree-sra.c (propagate_subaccesses_from_rhs): When a non-scalar access on the LHS is replaced with a scalar access, propagate the TYPE_REVERSE_STORAGE_ORDER flag of the type of the original access. gcc/testsuite/ChangeLog * gnat.dg/opt85.ads, gnat.dg/opt85.adb: New test.
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 4793b48..fcba7fb 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2758,6 +2758,9 @@ propagate_subaccesses_from_rhs (struct access *lacc, struct access *racc)
}
if (!lacc->first_child && !racc->first_child)
{
+ /* We are about to change the access type from aggregate to scalar,
+ so we need to put the reverse flag onto the access, if any. */
+ const bool reverse = TYPE_REVERSE_STORAGE_ORDER (lacc->type);
tree t = lacc->base;
lacc->type = racc->type;
@@ -2772,9 +2775,12 @@ propagate_subaccesses_from_rhs (struct access *lacc, struct access *racc)
lacc->expr = build_ref_for_model (EXPR_LOCATION (lacc->base),
lacc->base, lacc->offset,
racc, NULL, false);
+ if (TREE_CODE (lacc->expr) == MEM_REF)
+ REF_REVERSE_STORAGE_ORDER (lacc->expr) = reverse;
lacc->grp_no_warning = true;
lacc->grp_same_access_path = false;
}
+ lacc->reverse = reverse;
}
return ret;
}