Made the code that logs indirect-goto referals be a little more efficient.

This commit is contained in:
Greg King
2019-04-22 14:27:36 -04:00
parent 55ce618bf2
commit 214c90f957

View File

@@ -79,7 +79,6 @@ void GotoStatement (void)
ExprDesc desc; ExprDesc desc;
CodeEntry *E; CodeEntry *E;
unsigned char val; unsigned char val;
unsigned I;
NextToken (); NextToken ();
@@ -135,27 +134,25 @@ void GotoStatement (void)
ConsumeRBrack (); ConsumeRBrack ();
/* Loop over all target labels, specifying this as a jump point. /* Loop over all target labels, specifying this as a jump point.
** It's not exact - if there's multiple gotos, the last will be used, ** It's not exact -- if there's multiple gotos, the last will be used;
** but it's only needed so the optimizer does not remove the labels. ** but, it's needed only so the optimizer does not remove the labels.
*/ */
I = CS_GetEntryCount (CS->Code) - 1; E = CS_GetEntry (CS->Code, CS_GetEntryCount (CS->Code) - 1);
E = CS_GetEntry (CS->Code, I);
tab = GetLabelSymTab (); tab = GetLabelSymTab ();
if (tab) { if (tab) {
cur = tab->SymHead; cur = tab->SymHead;
while (cur) { while (cur) {
if ((cur->Flags & (SC_LABEL|SC_GOTO_IND)) == (SC_LABEL|SC_GOTO_IND)) { if ((cur->Flags & SC_GOTO_IND) != 0) {
cur->V.L.IndJumpFrom = E; cur->V.L.IndJumpFrom = E;
} }
cur = cur->NextSym; cur = cur->NextSym;
} }
} }
} else { /* It was not TOK_IDENT, or we couldn't find the symbol */ } else {
/* It was not TOK_IDENT, or we couldn't find the symbol */
Error ("Array name expected"); Error ("Array name expected");
} }
} else { } else {
Error ("Label name expected"); Error ("Label name expected");
} }
} }
@@ -170,6 +167,7 @@ void DoLabel (void)
/* Emit the jump label */ /* Emit the jump label */
CodeLabel* L = CS_AddLabel (CS->Code, LocalLabelName (Entry->V.L.Label)); CodeLabel* L = CS_AddLabel (CS->Code, LocalLabelName (Entry->V.L.Label));
if (Entry->V.L.IndJumpFrom) { if (Entry->V.L.IndJumpFrom) {
CollAppend (&L->JumpFrom, Entry->V.L.IndJumpFrom); CollAppend (&L->JumpFrom, Entry->V.L.IndJumpFrom);
} }