diff options
author | Alan Lawrence <alan.lawrence@arm.com> | 2016-03-10 12:19:45 +0000 |
---|---|---|
committer | Alan Lawrence <alalaw01@gcc.gnu.org> | 2016-03-10 12:19:45 +0000 |
commit | 71017a7b7837a4eeb1d1c0b2b155c6567f4f3d95 (patch) | |
tree | 53a07b60bfba985927686a3c1f4608c6205aaca9 /gcc/tree-dfa.c | |
parent | 4b2066179084192b65d8e56e51c29bccaef4cfe9 (diff) | |
download | gcc-71017a7b7837a4eeb1d1c0b2b155c6567f4f3d95.zip gcc-71017a7b7837a4eeb1d1c0b2b155c6567f4f3d95.tar.gz gcc-71017a7b7837a4eeb1d1c0b2b155c6567f4f3d95.tar.bz2 |
Add -funconstrained-commons to work around PR/69368 (and others) in SPEC2006
gcc/:
* common.opt (funconstrained-commons, flag_unconstrained_commons): New.
* tree.c (array_at_struct_end_p): Do not limit to size of decl for
DECL_COMMONS if flag_unconstrained_commons is set.
* tree-dfa.c (get_ref_base_and_extent): Likewise.
* doc/invoke.texi (Optimize Options): Add -funconstrained-commons.
(funconstrained-commons): Document.
gcc/testsuite:
* gfortran.dg/unconstrained_commons.f: New.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r234106
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r-- | gcc/tree-dfa.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 0e98056..f133abc 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -612,9 +612,22 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (DECL_P (exp)) { + if (flag_unconstrained_commons + && TREE_CODE (exp) == VAR_DECL && DECL_COMMON (exp)) + { + tree sz_tree = TYPE_SIZE (TREE_TYPE (exp)); + /* If size is unknown, or we have read to the end, assume there + may be more to the structure than we are told. */ + if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE + || (seen_variable_array_ref + && (sz_tree == NULL_TREE + || TREE_CODE (sz_tree) != INTEGER_CST + || (bit_offset + maxsize == wi::to_offset (sz_tree))))) + maxsize = -1; + } /* If maxsize is unknown adjust it according to the size of the base decl. */ - if (maxsize == -1 + else if (maxsize == -1 && DECL_SIZE (exp) && TREE_CODE (DECL_SIZE (exp)) == INTEGER_CST) maxsize = wi::to_offset (DECL_SIZE (exp)) - bit_offset; |