aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-09-22 18:29:43 +0000
committerRichard Stallman <rms@gnu.org>1993-09-22 18:29:43 +0000
commite9b7093a9f2c1125a3c0adc8f2a8d77f562631ff (patch)
treec849f423fab0fec4dc2dd8d45929eeaba832cbec /gcc
parent635b1dad854b47d35904cbed864193e6345b91ea (diff)
downloadgcc-e9b7093a9f2c1125a3c0adc8f2a8d77f562631ff.zip
gcc-e9b7093a9f2c1125a3c0adc8f2a8d77f562631ff.tar.gz
gcc-e9b7093a9f2c1125a3c0adc8f2a8d77f562631ff.tar.bz2
(combine_temp_slots): Handle deletion properly.
Free the RTL that is allocated. From-SVN: r5401
Diffstat (limited to 'gcc')
-rw-r--r--gcc/function.c62
1 files changed, 43 insertions, 19 deletions
diff --git a/gcc/function.c b/gcc/function.c
index 1e27500..b75e496 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -782,30 +782,54 @@ combine_temp_slots ()
{
struct temp_slot *p, *q;
struct temp_slot *prev_p, *prev_q;
+ /* Determine where to free back to after this function. */
+ rtx free_pointer = rtx_alloc (CONST_INT);
- for (p = temp_slots, prev_p = 0; p; prev_p = p, p = p->next)
- if (! p->in_use && GET_MODE (p->slot) == BLKmode)
- for (q = p->next, prev_q = p; q; prev_q = q, q = q->next)
- if (! q->in_use && GET_MODE (q->slot) == BLKmode)
+ for (p = temp_slots, prev_p = 0; p; p = prev_p ? prev_p->next : temp_slots)
+ {
+ int delete_p = 0;
+ if (! p->in_use && GET_MODE (p->slot) == BLKmode)
+ for (q = p->next, prev_q = p; q; q = prev_q->next)
{
- if (rtx_equal_p (plus_constant (XEXP (p->slot, 0), p->size),
- XEXP (q->slot, 0)))
- {
- /* Combine q into p. */
- p->size += q->size;
- prev_q->next = q->next;
- }
- else if (rtx_equal_p (plus_constant (XEXP (q->slot, 0), q->size),
- XEXP (p->slot, 0)))
+ int delete_q = 0;
+ if (! q->in_use && GET_MODE (q->slot) == BLKmode)
{
- /* Combine p into q. */
- q->size += p->size;
- if (prev_p)
- prev_p->next = p->next;
- else
- temp_slots = p->next;
+ if (rtx_equal_p (plus_constant (XEXP (p->slot, 0), p->size),
+ XEXP (q->slot, 0)))
+ {
+ /* Q comes after P; combine Q into P. */
+ p->size += q->size;
+ delete_q = 1;
+ }
+ else if (rtx_equal_p (plus_constant (XEXP (q->slot, 0), q->size),
+ XEXP (p->slot, 0)))
+ {
+ /* P comes after Q; combine P into Q. */
+ q->size += p->size;
+ delete_p = 1;
+ break;
+ }
}
+ /* Either delete Q or advance past it. */
+ if (delete_q)
+ prev_q->next = q->next;
+ else
+ prev_q = q;
}
+ /* Either delete P or advance past it. */
+ if (delete_p)
+ {
+ if (prev_p)
+ prev_p->next = p->next;
+ else
+ temp_slots = p->next;
+ }
+ else
+ prev_p = p;
+ }
+
+ /* Free all the RTL made by plus_constant. */
+ rtx_free (free_pointer);
}
/* If X could be a reference to a temporary slot, mark that slot as belonging