aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2005-04-11 22:06:46 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2005-04-11 18:06:46 -0400
commitf8d66d34f711e94a48b1eb28ab0fa25c6e1404c9 (patch)
treeea3a6eedbf40f8febad0a55f21fd8d5f0af2123d /gcc
parent9f32d037484306f1045b661d9bf29e893d846ede (diff)
downloadgcc-f8d66d34f711e94a48b1eb28ab0fa25c6e1404c9.zip
gcc-f8d66d34f711e94a48b1eb28ab0fa25c6e1404c9.tar.gz
gcc-f8d66d34f711e94a48b1eb28ab0fa25c6e1404c9.tar.bz2
re PR middle-end/20933 (gcc can no longer bootstrap itself)
PR tree-optimization/20933 * tree-ssa-alias.c (compute_flow_insensitive_aliasing): Move logic to reject aliases between read-only and writable variables ... (may_alias_p): ... here. (get_tmt_for): Do not associate read-only tags to pointers whose pointed-to type is not read-only. * tree-ssa.c (verify_ssa): Check that memory stores have at least one V_MAY_DEF or V_MUST_DEF. testsuite/ChangeLog PR tree-optimization/20933 * gcc.dg/tree-ssa/pr20933.c: New test. From-SVN: r97988
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr20933.c70
-rw-r--r--gcc/tree-ssa-alias.c24
-rw-r--r--gcc/tree-ssa.c29
5 files changed, 130 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0c7d095..6d4dd6a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2005-04-11 Diego Novillo <dnovillo@redhat.com>
+
+ PR tree-optimization/20933
+ * tree-ssa-alias.c (compute_flow_insensitive_aliasing): Move
+ logic to reject aliases between read-only and writable
+ variables ...
+ (may_alias_p): ... here.
+ (get_tmt_for): Do not associate read-only tags to pointers
+ whose pointed-to type is not read-only.
+ * tree-ssa.c (verify_ssa): Check that memory stores have at
+ least one V_MAY_DEF or V_MUST_DEF.
+
2005-04-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR/17092
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2b10695..5271167 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-11 Diego Novillo <dnovillo@redhat.com>
+
+ PR tree-optimization/20933
+ * gcc.dg/tree-ssa/pr20933.c: New test.
+
2005-04-11 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* gfortran.dg/fold_nearest.f90: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20933.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20933.c
new file mode 100644
index 0000000..d32d600
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20933.c
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern __SIZE_TYPE__ strlen (__const char *__s)
+ __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
+ __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
+extern char *getenv (__const char *__name) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
+extern int access (__const char *__name, int __type) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
+extern void * xmalloc (__SIZE_TYPE__) __attribute__ ((__malloc__));
+
+static __inline__ const char *
+try (const char *dir, const char *base)
+{
+ if (base != 0)
+ return base;
+ if (dir != 0
+ && access (dir, 4 | 2 | 1) == 0)
+ return dir;
+ return 0;
+}
+
+static const char tmp[] = { '/', 't', 'm', 'p', 0 };
+static const char usrtmp[] =
+{ '/', 'u', 's', 'r', '/', 't', 'm', 'p', 0 };
+static const char vartmp[] =
+{ '/', 'v', 'a', 'r', '/', 't', 'm', 'p', 0 };
+
+static char *memoized_tmpdir;
+char *
+choose_tmpdir (void)
+{
+ const char *base = 0;
+ char *tmpdir;
+ unsigned int len;
+
+ if (memoized_tmpdir)
+ return memoized_tmpdir;
+
+ base = try (getenv ("TMPDIR"), base);
+ base = try (getenv ("TMP"), base);
+ base = try (getenv ("TEMP"), base);
+
+
+ base = try ("/tmp", base);
+
+
+
+ base = try (vartmp, base);
+ base = try (usrtmp, base);
+ base = try (tmp, base);
+
+
+ if (base == 0)
+ base = ".";
+
+
+
+ len = strlen (base);
+ tmpdir = xmalloc (len + 2);
+ strcpy (tmpdir, base);
+ /* Alias analysis was associating read-only memory tags to pointers
+ that are not read-only. We would then not issue any V_MAY_DEF in
+ this store. */
+ tmpdir[len] = '/';
+ tmpdir[len+1] = '\0';
+
+ memoized_tmpdir = tmpdir;
+ return tmpdir;
+}
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 7d8e783..c0bce92 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1001,10 +1001,6 @@ compute_flow_insensitive_aliasing (struct alias_info *ai)
if (!tag_stored_p && !var_stored_p)
continue;
- if ((unmodifiable_var_p (tag) && !unmodifiable_var_p (var))
- || (unmodifiable_var_p (var) && !unmodifiable_var_p (tag)))
- continue;
-
if (may_alias_p (p_map->var, p_map->set, var, v_map->set))
{
subvar_t svars;
@@ -1719,6 +1715,16 @@ may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set,
return false;
}
+ /* If either MEM or VAR is a read-only global and the other one
+ isn't, then PTR cannot point to VAR. */
+ if ((unmodifiable_var_p (mem) && !unmodifiable_var_p (var))
+ || (unmodifiable_var_p (var) && !unmodifiable_var_p (mem)))
+ {
+ alias_stats.alias_noalias++;
+ alias_stats.simple_resolved++;
+ return false;
+ }
+
m_ann = var_ann (mem);
gcc_assert (m_ann->mem_tag_kind == TYPE_TAG);
@@ -2319,9 +2325,11 @@ get_tmt_for (tree ptr, struct alias_info *ai)
for (i = 0, tag = NULL_TREE; i < ai->num_pointers; i++)
{
struct alias_map_d *curr = ai->pointers[i];
- if (tag_set == curr->set)
+ tree curr_tag = var_ann (curr->var)->type_mem_tag;
+ if (tag_set == curr->set
+ && TYPE_READONLY (tag_type) == TYPE_READONLY (TREE_TYPE (curr_tag)))
{
- tag = var_ann (curr->var)->type_mem_tag;
+ tag = curr_tag;
break;
}
}
@@ -2356,6 +2364,10 @@ get_tmt_for (tree ptr, struct alias_info *ai)
pointed-to type. */
gcc_assert (tag_set == get_alias_set (tag));
+ /* If PTR's pointed-to type is read-only, then TAG's type must also
+ be read-only. */
+ gcc_assert (TYPE_READONLY (tag_type) == TYPE_READONLY (TREE_TYPE (tag)));
+
return tag;
}
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index c152f82..1e232e3 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -707,16 +707,37 @@ verify_ssa (bool check_modified_stmt)
goto err;
}
+ if (TREE_CODE (stmt) == MODIFY_EXPR
+ && TREE_CODE (TREE_OPERAND (stmt, 0)) != SSA_NAME)
+ {
+ tree lhs, base_address;
+
+ lhs = TREE_OPERAND (stmt, 0);
+ base_address = get_base_address (lhs);
- if (stmt_ann (stmt)->makes_aliased_stores
- && NUM_V_MAY_DEFS (STMT_V_MAY_DEF_OPS (stmt)) == 0)
+ if (base_address
+ && SSA_VAR_P (base_address)
+ && NUM_V_MAY_DEFS (STMT_V_MAY_DEF_OPS (stmt)) == 0
+ && NUM_V_MUST_DEFS (STMT_V_MUST_DEF_OPS (stmt)) == 0)
{
- error ("Statement makes aliased stores, but has no V_MAY_DEFS");
+ error ("Statement makes a memory store, but has no "
+ "V_MAY_DEFS nor V_MUST_DEFS");
print_generic_stmt (stderr, stmt, TDF_VOPS);
goto err;
}
+ }
+
+
+ if (stmt_ann (stmt)->makes_aliased_stores
+ && NUM_V_MAY_DEFS (STMT_V_MAY_DEF_OPS (stmt)) == 0)
+ {
+ error ("Statement makes aliased stores, but has no V_MAY_DEFS");
+ print_generic_stmt (stderr, stmt, TDF_VOPS);
+ goto err;
+ }
- FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES | SSA_OP_ALL_KILLS)
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
+ SSA_OP_ALL_USES | SSA_OP_ALL_KILLS)
{
op = USE_FROM_PTR (use_p);
if (verify_use (bb, definition_block[SSA_NAME_VERSION (op)],