From e9b7093a9f2c1125a3c0adc8f2a8d77f562631ff Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Wed, 22 Sep 1993 18:29:43 +0000 Subject: [PATCH] (combine_temp_slots): Handle deletion properly. Free the RTL that is allocated. From-SVN: r5401 --- gcc/function.c | 62 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/gcc/function.c b/gcc/function.c index 1e2750022b1..b75e4969938 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 -- 2.30.2