mirror of
https://github.com/cc65/cc65.git
synced 2025-02-02 15:37:58 +00:00
Fixed some bugs
git-svn-id: svn://svn.cc65.org/cc65/trunk@1064 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
c4627941e8
commit
92a4c51753
@ -214,7 +214,9 @@ unsigned OptDeadJumps (CodeSeg* S)
|
|||||||
/* Check if it's a branch, if it has a local target, and if the target
|
/* Check if it's a branch, if it has a local target, and if the target
|
||||||
* is the next instruction.
|
* is the next instruction.
|
||||||
*/
|
*/
|
||||||
if (E->AM == AM65_BRA && E->JumpTo && E->JumpTo->Owner == CS_GetEntry (S, I+1)) {
|
if (E->AM == AM65_BRA &&
|
||||||
|
E->JumpTo &&
|
||||||
|
E->JumpTo->Owner == CS_GetNextEntry (S, I)) {
|
||||||
|
|
||||||
/* Delete the dead jump */
|
/* Delete the dead jump */
|
||||||
CS_DelEntry (S, I);
|
CS_DelEntry (S, I);
|
||||||
@ -467,30 +469,24 @@ unsigned OptJumpTarget (CodeSeg* S)
|
|||||||
CodeEntry* E1; /* Entry 1 */
|
CodeEntry* E1; /* Entry 1 */
|
||||||
CodeEntry* E2; /* Entry 2 */
|
CodeEntry* E2; /* Entry 2 */
|
||||||
CodeEntry* T1; /* Jump target entry 1 */
|
CodeEntry* T1; /* Jump target entry 1 */
|
||||||
CodeEntry* T2; /* Jump target entry 2 */
|
|
||||||
CodeLabel* TL1; /* Target label 1 */
|
CodeLabel* TL1; /* Target label 1 */
|
||||||
unsigned TI; /* Target index */
|
|
||||||
|
|
||||||
/* Walk over the entries */
|
/* Walk over the entries */
|
||||||
unsigned I = 0;
|
unsigned I = 0;
|
||||||
while (I < CS_GetEntryCount (S)) {
|
while (I < CS_GetEntryCount (S)) {
|
||||||
|
|
||||||
/* Get next entry */
|
/* Get next entry */
|
||||||
E2 = CS_GetEntry (S, I+1);
|
E2 = CS_GetNextEntry (S, I);
|
||||||
|
|
||||||
/* Check if we have a jump or branch, and a matching label */
|
/* Check if we have a jump or branch, and a matching label */
|
||||||
if ((E2->Info & OF_UBRA) != 0 && E2->JumpTo) {
|
if (E2 && (E2->Info & OF_UBRA) != 0 && E2->JumpTo) {
|
||||||
|
|
||||||
/* Get the target instruction for the label */
|
/* Get the entry preceeding the branch target */
|
||||||
T2 = E2->JumpTo->Owner;
|
T1 = CS_GetPrevEntry (S, CS_GetEntryIndex (S, E2->JumpTo->Owner));
|
||||||
|
if (T1 == 0) {
|
||||||
/* Get the entry preceeding this one (if possible) */
|
/* There is no such entry */
|
||||||
TI = CS_GetEntryIndex (S, T2);
|
|
||||||
if (TI == 0) {
|
|
||||||
/* There is no entry before this one */
|
|
||||||
goto NextEntry;
|
goto NextEntry;
|
||||||
}
|
}
|
||||||
T1 = CS_GetEntry (S, TI-1);
|
|
||||||
|
|
||||||
/* Get the entry preceeding the jump */
|
/* Get the entry preceeding the jump */
|
||||||
E1 = CS_GetEntry (S, I);
|
E1 = CS_GetEntry (S, I);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user