aboutsummaryrefslogtreecommitdiff
path: root/gcc/alias.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-06-25 15:14:41 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-06-25 15:14:41 +0000
commit41472af8777035219decfe1cb4742ce2b3ed8e38 (patch)
treeaf8828e1df0f3e051eb29c58c7d958cd177e474d /gcc/alias.c
parent9c606f693ddca43b89097388cfdeeffaead030df (diff)
downloadgcc-41472af8777035219decfe1cb4742ce2b3ed8e38.zip
gcc-41472af8777035219decfe1cb4742ce2b3ed8e38.tar.gz
gcc-41472af8777035219decfe1cb4742ce2b3ed8e38.tar.bz2
invoke.texi (-fstrict-aliasing): Document.
* invoke.texi (-fstrict-aliasing): Document. * rtl.texi (MEM_ALIAS_SET): Document. * flags.h (flag_strict_aliasing): Declare. * toplev.c (flag_strict_aliasing): Define. (f_options): Add -strict-aliasing. (main): Set flag_strict_aliasing if -O2 or higher. * tree.h (tree_type): Add alias_set field. (TYPE_ALIAS_SET): New macro. (TYPE_ALIAS_SET_KNOWN_P): Likewise. (get_alias_set): Declare. * tree.c (lang_get_alias_set): Define. (make_node): Initialize TYPE_ALIAS_SET. (get_alias_set): New function. * print-tree.c (print_node): Dump the alias set for a type. * c-tree.h (c_get_alias_set): Declare. * c-common.c (c_get_alias_set): New function. * c-decl.c (init_decl_processing): Set lang_get_alias_set. * expr.c (protect_from_queue): Propogage alias sets. (expand_assignment): Calculate alias set for new MEMs. (expand_expr): Likewise. * function.c (put_var_into_stack): Likewise. (put_reg_into_stack): Likewise. (gen_mem_addressof): Likewise. (assign_parms): Likewise. * stmt.c (expand_decl): Likewise. * varasm.c (make_decl_rtl): Eliminate redundant clearing of DECL_RTL. Calculate alias set for new MEMs. * rtl.def (REG): Add dummy operand. (MEM): Add extra operand to store the MEM_ALIAS_SET. * rtl.h (MEM_ALIAS_SET): New macro. (gen_rtx_MEM): Declare. * emit-rtl.c (gen_rtx_MEM): New function. * gengenrtl.c (sepcial_rtx): Make MEMs special. * alias.c (CHECK_ALIAS_SETS_FOR_CONSISTENCY): New macro. (DIFFERENT_ALIAS_SETS_P): Likewise. (canon_rtx): Propogate the alias set to the new MEM. (true_dependence): Check the alias sets. (anti_dependence): Likewise. (output_dependence): Likewise. * explow.c (stabilize): Progoate alias sets. * integrate.c (copy_rtx_and_substitute): Likewise. * final.c (alter_subreg): Make sure not to leave MEM_IN_STRUCT_P in an unpredictable state. Propogate alias sets. * reload1.c (reload): Clear MEM_ALIAS_SET for new MEMs about which we have no alias information. From-SVN: r20719
Diffstat (limited to 'gcc/alias.c')
-rw-r--r--gcc/alias.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/alias.c b/gcc/alias.c
index 99df4fa..ab65bc4 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -42,6 +42,28 @@ static rtx find_base_value PROTO((rtx));
#define SIZE_FOR_MODE(X) (GET_MODE_SIZE (GET_MODE (X)))
+/* Perform a basic sanity check. Namely, that there are
+ no alias sets if we're not doing strict aliasing. This helps
+ to catch bugs whereby someone uses PUT_CODE, but doesn't clear
+ MEM_ALIAS_SET, or where a MEM is allocated in some way other
+ than by the use of gen_rtx_MEM, and the MEM_ALIAS_SET is not
+ cleared. */
+#ifdef ENABLE_CHECKING
+#define CHECK_ALIAS_SETS_FOR_CONSISTENCY(MEM1, MEM2) \
+ (!flag_strict_aliasing \
+ && (MEM_ALIAS_SET (MEM1) || MEM_ALIAS_SET (MEM2)) \
+ ? (abort (), 0) : 0)
+#else
+#define CHECK_ALIAS_SETS_FOR_CONSISTENCY(MEM1, MEM2) 0
+#endif
+
+/* Returns nonzero if MEM1 and MEM2 do not alias because they are in
+ different alias sets. */
+#define DIFFERENT_ALIAS_SETS_P(MEM1, MEM2) \
+ (CHECK_ALIAS_SETS_FOR_CONSISTENCY(MEM1, MEM2), \
+ MEM_ALIAS_SET (MEM1) && MEM_ALIAS_SET (MEM2) \
+ && MEM_ALIAS_SET (MEM1) != MEM_ALIAS_SET (MEM2))
+
/* Cap the number of passes we make over the insns propagating alias
information through set chains.
@@ -372,6 +394,7 @@ canon_rtx (x)
MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
+ MEM_ALIAS_SET (new) = MEM_ALIAS_SET (x);
x = new;
}
}
@@ -874,6 +897,9 @@ true_dependence (mem, mem_mode, x, varies)
if (MEM_VOLATILE_P (x) && MEM_VOLATILE_P (mem))
return 1;
+ if (DIFFERENT_ALIAS_SETS_P (x, mem))
+ return 0;
+
/* If X is an unchanging read, then it can't possibly conflict with any
non-unchanging store. It may conflict with an unchanging write though,
because there may be a single store to this address to initialize it.
@@ -947,6 +973,9 @@ anti_dependence (mem, x)
x = canon_rtx (x);
mem = canon_rtx (mem);
+ if (DIFFERENT_ALIAS_SETS_P (x, mem))
+ return 0;
+
x_addr = XEXP (x, 0);
mem_addr = XEXP (mem, 0);
@@ -978,6 +1007,9 @@ output_dependence (mem, x)
x = canon_rtx (x);
mem = canon_rtx (mem);
+ if (DIFFERENT_ALIAS_SETS_P (x, mem))
+ return 0;
+
return (memrefs_conflict_p (SIZE_FOR_MODE (mem), XEXP (mem, 0),
SIZE_FOR_MODE (x), XEXP (x, 0), 0)
&& ! (MEM_IN_STRUCT_P (mem) && rtx_addr_varies_p (mem)