+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
+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.
--- /dev/null
+/* { 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;
+}
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;
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);
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;
}
}
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;
}
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)],