From a0496ca53d4355d50027f91a21ccfe413c79ca39 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 6 Oct 2002 19:03:12 +0000 Subject: [PATCH] Fixed an omission in AdjustStackOffset. Use CS_IsBasicBlock in OptStackOps. git-svn-id: svn://svn.cc65.org/cc65/trunk@1450 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/coptstop.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index cca49c871..625ddfe70 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -94,14 +94,27 @@ static unsigned AdjustStackOffset (CodeSeg* S, unsigned Start, unsigned Stop, CodeEntry* E = CS_GetEntry (S, I); - if (E->Use & REG_SP) { - - CodeEntry* P; + int NeedCorrection = 0; + if ((E->Use & REG_SP) != 0) { /* Check for some things that should not happen */ CHECK (E->AM == AM65_ZP_INDY || E->RI->In.RegY >= (short) Offs); CHECK (strcmp (E->Arg, "sp") == 0); + /* We need to correct this one */ + NeedCorrection = 1; + + } else if (CE_IsCall (E, "ldaxysp")) { + + /* We need to correct this one */ + NeedCorrection = 1; + + } + + if (NeedCorrection) { + + CodeEntry* P; + /* Get the code entry before this one. If it's a LDY, adjust the * value. */ @@ -632,8 +645,7 @@ unsigned OptStackOps (CodeSeg* S) * It depends on the code between the two if we can handle/transform the * sequence, so check this code for the following list of things: * - * - there must not be a jump or conditional branch (this may - * get relaxed later). + * - the range must be a basic block (one entry, one exit) * - there may not be accesses to local variables with unknown * offsets (because we have to adjust these offsets). * - no subroutine calls @@ -653,8 +665,7 @@ unsigned OptStackOps (CodeSeg* S) if ((E->Info & OF_BRA) != 0 || ((E->Use & REG_SP) != 0 && - (E->AM != AM65_ZP_INDY || E->RI->In.RegY < 0)) || - CE_HasLabel (E)) { + (E->AM != AM65_ZP_INDY || E->RI->In.RegY < 0))) { /* All this stuff is not allowed in a sequence */ InSeq = 0; @@ -696,6 +707,11 @@ unsigned OptStackOps (CodeSeg* S) } } + /* Determine if we have a basic block */ + if (PreCondOk) { + PreCondOk = CS_IsBasicBlock (S, Push, I); + } + /* If preconditions are ok, call the optimizer function */ if (PreCondOk) { -- 2.39.5