From e8964cde74f7667b568fb8d841cf85e6978cc9d1 Mon Sep 17 00:00:00 2001 From: uz Date: Tue, 12 Feb 2013 19:51:11 +0000 Subject: [PATCH] Quick fix for a problem in the OptLoad3 function. The fix isn't perfect and may fail for inline assembly code, but at least it's less buggy than before. git-svn-id: svn://svn.cc65.org/cc65/trunk@5982 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codeopt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 758d4893d..9006ea8ff 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -248,6 +248,8 @@ static unsigned OptLoad3 (CodeSeg* S) /* Check if this insn is a load */ if (E->Info & OF_LOAD) { + CodeEntry* N; + /* If we had a preceeding load that is identical, remove this one. * If it is not identical, or we didn't have one, remember it. */ @@ -255,7 +257,9 @@ static unsigned OptLoad3 (CodeSeg* S) E->OPC == Load->OPC && E->AM == Load->AM && ((E->Arg == 0 && Load->Arg == 0) || - strcmp (E->Arg, Load->Arg) == 0)) { + strcmp (E->Arg, Load->Arg) == 0) && + (N = CS_GetNextEntry (S, I)) != 0 && + (N->Info & OF_CBRA) == 0) { /* Now remove the call to the subroutine */ CS_DelEntry (S, I);