Fixed a bug

git-svn-id: svn://svn.cc65.org/cc65/trunk@3513 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2005-05-17 12:42:34 +00:00
parent 2ef65e7eda
commit 412a1300f9
2 changed files with 29 additions and 22 deletions

View File

@@ -144,7 +144,7 @@ static void SetUseChgInfo (CodeEntry* E, const OPCDesc* D)
* lookup the information about this function and use it. The jump itself * lookup the information about this function and use it. The jump itself
* does not change any registers, so we don't need to use the data from D. * does not change any registers, so we don't need to use the data from D.
*/ */
if ((E->Info & (OF_BRA | OF_CALL)) != 0 && E->JumpTo == 0) { if ((E->Info & (OF_UBRA | OF_CALL)) != 0 && E->JumpTo == 0) {
/* A subroutine call or jump to external symbol (function exit) */ /* A subroutine call or jump to external symbol (function exit) */
GetFuncInfo (E->Arg, &E->Use, &E->Chg); GetFuncInfo (E->Arg, &E->Use, &E->Chg);
} else { } else {

View File

@@ -416,7 +416,7 @@ static unsigned GetRegInfo2 (CodeSeg* S,
/* Evaluate the used registers */ /* Evaluate the used registers */
R = E->Use; R = E->Use;
if (E->OPC == OP65_RTS || if (E->OPC == OP65_RTS ||
((E->Info & OF_BRA) != 0 && E->JumpTo == 0)) { ((E->Info & OF_UBRA) != 0 && E->JumpTo == 0)) {
/* This instruction will leave the function */ /* This instruction will leave the function */
R |= S->ExitRegs; R |= S->ExitRegs;
} }
@@ -472,30 +472,37 @@ static unsigned GetRegInfo2 (CodeSeg* S,
*/ */
} else if ((E->Info & OF_CBRA) != 0) { } else if ((E->Info & OF_CBRA) != 0) {
/* Recursively determine register usage at the branch target */
unsigned U1;
unsigned U2;
if (E->JumpTo) { if (E->JumpTo) {
/* Recursively determine register usage at the branch target */ /* Jump to internal label */
unsigned U1;
unsigned U2;
U1 = GetRegInfo2 (S, E->JumpTo->Owner, -1, Visited, Used, Unused, Wanted); U1 = GetRegInfo2 (S, E->JumpTo->Owner, -1, Visited, Used, Unused, Wanted);
if (U1 == REG_ALL) {
/* All registers used, no need for second call */
return REG_AXY;
}
if (Index < 0) {
Index = CS_GetEntryIndex (S, E);
}
if ((E = CS_GetEntry (S, ++Index)) == 0) {
Internal ("GetRegInfo2: No next entry!");
}
U2 = GetRegInfo2 (S, E, Index, Visited, Used, Unused, Wanted);
return U1 | U2; /* Used in any of the branches */
} else { } else {
/* Jump to global symbol */
break; /* Jump to external label. This will effectively exit the
} * function, so we use the exitregs information here.
*/
U1 = S->ExitRegs;
}
/* Get the next entry */
if (Index < 0) {
Index = CS_GetEntryIndex (S, E);
}
if ((E = CS_GetEntry (S, ++Index)) == 0) {
Internal ("GetRegInfo2: No next entry!");
}
/* Follow flow if branch not taken */
U2 = GetRegInfo2 (S, E, Index, Visited, Used, Unused, Wanted);
/* Registers are used if they're use in any of the branches */
return U1 | U2;
} else { } else {