summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1998-11-18 17:52:45 +0000
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1998-11-18 17:52:45 +0000
commit10b31fee73b1b6f830e29a9b1eb3b2bc9b96e314 (patch)
treef539ac17b4d4edc798e64ba1abc5ce4cbdee69f4
parentc7ac7ebb94846fe3b598e38e02f2e80c8cb9630f (diff)
downloadgcc-10b31fee73b1b6f830e29a9b1eb3b2bc9b96e314.tar.gz
Fix memory corruption probelem in reload.
* reload.c (find_reloads_address_part): If have a CONST_INT, create a new one before passing it to force_const_mem. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23698 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/reload.c23
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9336c23b194..bcc3614c81b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
Wed Nov 18 16:31:28 1998 Jim Wilson <wilson@cygnus.com>
+ * reload.c (find_reloads_address_part): If have a CONST_INT, create
+ a new one before passing it to force_const_mem.
+
* reload.c (find_reloads_toplev): Pass &x instead of NULL_PTR in
find_reloads_address call.
diff --git a/gcc/reload.c b/gcc/reload.c
index 0be683e3537..9e59eba1983 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -5517,7 +5517,20 @@ find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
&& (! LEGITIMATE_CONSTANT_P (x)
|| PREFERRED_RELOAD_CLASS (x, class) == NO_REGS))
{
- rtx tem = x = force_const_mem (mode, x);
+ rtx tem;
+
+ /* If this is a CONST_INT, it could have been created by a
+ plus_constant call in eliminate_regs, which means it may be
+ on the reload_obstack. reload_obstack will be freed later, so
+ we can't allow such RTL to be put in the constant pool. There
+ is code in force_const_mem to check for this case, but it doesn't
+ work because we have already popped off the reload_obstack, so
+ rtl_obstack == saveable_obstack is true at this point. */
+ if (GET_CODE (x) == CONST_INT)
+ tem = x = force_const_mem (mode, GEN_INT (INTVAL (x)));
+ else
+ tem = x = force_const_mem (mode, x);
+
find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
opnum, type, ind_levels, 0);
}
@@ -5527,7 +5540,13 @@ find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
&& (! LEGITIMATE_CONSTANT_P (XEXP (x, 1))
|| PREFERRED_RELOAD_CLASS (XEXP (x, 1), class) == NO_REGS))
{
- rtx tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
+ rtx tem;
+
+ /* See comment above. */
+ if (GET_CODE (XEXP (x, 1)) == CONST_INT)
+ tem = force_const_mem (GET_MODE (x), GEN_INT (INTVAL (XEXP (x, 1))));
+ else
+ tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
x = gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0), tem);
find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),