===================================================================
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.
#include "builtins.h"
#include "tree-chkp.h"
#include "rtl-chkp.h"
+#include "alias.h"
/* Some systems use __main in a way incompatible with its use in gcc, in these
cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
@@ -2622,12 +2623,17 @@ expand_call_stmt (gcall *stmt)
unsigned int ix;
tree dtemp;
+ gcc_assert (!no_new_alias_sets);
+ no_new_alias_sets = true;
+
if (debug_args)
for (ix = 1; (*debug_args)->iterate (ix, &dtemp); ix += 2)
{
gcc_assert (TREE_CODE (dtemp) == DEBUG_EXPR_DECL);
expand_debug_expr (dtemp);
}
+
+ no_new_alias_sets = false;
}
lhs = gimple_call_lhs (stmt);
@@ -4080,6 +4086,8 @@ expand_debug_expr (tree exp)
int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp));
addr_space_t as;
+ gcc_assert (no_new_alias_sets);
+
switch (TREE_CODE_CLASS (TREE_CODE (exp)))
{
case tcc_expression:
@@ -5219,12 +5227,12 @@ expand_debug_locations (void)
{
rtx_insn *insn;
rtx_insn *last = get_last_insn ();
- int save_strict_alias = flag_strict_aliasing;
/* New alias sets while setting up memory attributes cause
-fcompare-debug failures, even though it doesn't bring about any
codegen changes. */
- flag_strict_aliasing = 0;
+ gcc_assert (!no_new_alias_sets);
+ no_new_alias_sets = true;
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
if (DEBUG_INSN_P (insn))
@@ -5284,7 +5292,7 @@ expand_debug_locations (void)
avoid_complex_debug_insns (insn2, &INSN_VAR_LOCATION_LOC (insn2), 0);
}
- flag_strict_aliasing = save_strict_alias;
+ no_new_alias_sets = false;
}
/* Performs swapping operands of commutative operations to expand
===================================================================
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
#include "common/common-target.h"
#include "asan.h"
#include "rtl-iter.h"
+#include "alias.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h" /* Needed for external data declarations. */
@@ -1487,7 +1488,6 @@ make_decl_rtl (tree decl)
rtx
make_decl_rtl_for_debug (tree decl)
{
- unsigned int save_aliasing_flag;
rtx rtl;
if (DECL_RTL_SET_P (decl))
@@ -1496,18 +1496,16 @@ make_decl_rtl_for_debug (tree decl)
/* Kludge alert! Somewhere down the call chain, make_decl_rtl will
call new_alias_set. If running with -fcompare-debug, sometimes
we do not want to create alias sets that will throw the alias
- numbers off in the comparison dumps. So... clearing
- flag_strict_aliasing will keep new_alias_set() from creating a
- new set. */
- save_aliasing_flag = flag_strict_aliasing;
- flag_strict_aliasing = 0;
+ numbers off in the comparison dumps. */
+ bool save_no_new_alias_sets = no_new_alias_sets;
+ no_new_alias_sets = true;
rtl = DECL_RTL (decl);
/* Reset DECL_RTL back, as various parts of the compiler expects
DECL_RTL set meaning it is actually going to be output. */
SET_DECL_RTL (decl, NULL);
- flag_strict_aliasing = save_aliasing_flag;
+ no_new_alias_sets = save_no_new_alias_sets;
return rtl;
}
===================================================================
@@ -145,6 +145,9 @@ struct GTY(()) alias_set_entry {
bool has_pointer;
};
+/* When true we will not allocate any new alias sets. */
+bool no_new_alias_sets;
+
static int rtx_equal_for_memref_p (const_rtx, const_rtx);
static int memrefs_conflict_p (int, rtx, int, rtx, HOST_WIDE_INT);
static void record_set (rtx, const_rtx, void *);
@@ -1034,6 +1037,10 @@ get_alias_set (tree t)
gcc_checking_assert (p == TYPE_MAIN_VARIANT (p));
if (TYPE_ALIAS_SET_KNOWN_P (p))
set = TYPE_ALIAS_SET (p);
+ /* During debug statement expanding we can not allocate new alias sets
+ or the debug dumps will miscompare. */
+ else if (no_new_alias_sets)
+ return 0;
else
{
set = new_alias_set ();
@@ -1041,6 +1048,10 @@ get_alias_set (tree t)
}
}
}
+ /* During debug statement expanding we can not allocate new alias sets
+ or the debug dumps will miscompare. */
+ else if (no_new_alias_sets)
+ return 0;
/* Alias set of ptr_type_node is special and serve as universal pointer which
is TBAA compatible with every other pointer type. Be sure we have the
alias set built even for LTO which otherwise keeps all TYPE_CANONICAL
@@ -1060,6 +1071,11 @@ get_alias_set (tree t)
set = new_alias_set ();
}
+ /* Do not record alias set 0 if we are not creating new aliases. Perhaps
+ we needed new one during the recursion. */
+ if (!set && !no_new_alias_sets)
+ return 0;
+
TYPE_ALIAS_SET (t) = set;
/* If this is an aggregate type or a complex type, we must record any
@@ -1085,6 +1101,7 @@ get_alias_set (tree t)
alias_set_type
new_alias_set (void)
{
+ gcc_assert (!no_new_alias_sets);
if (flag_strict_aliasing)
{
if (alias_sets == 0)
===================================================================
@@ -37,6 +37,8 @@ extern void dump_alias_stats_in_alias_c
tree reference_alias_ptr_type (tree);
bool alias_ptr_types_compatible_p (tree, tree);
+extern bool no_new_alias_sets;
+
/* This alias set can be used to force a memory to conflict with all
other memories, creating a barrier across which no memory reference
can move. Note that there are other legacy ways to create such