* fixed peephole opitimizer removing some infinite loops (mantis #36139)

git-svn-id: trunk@43175 -
This commit is contained in:
Jonas Maebe 2019-10-12 21:39:48 +00:00
parent 6c29ecbd1c
commit 67fc9a7853

View File

@ -1553,7 +1553,7 @@ Unit AoptObj;
procedure TAOptObj.PeepHoleOptPass1; procedure TAOptObj.PeepHoleOptPass1;
var var
p,hp1,hp2 : tai; p,hp1,hp2,hp3 : tai;
stoploop:boolean; stoploop:boolean;
begin begin
repeat repeat
@ -1649,13 +1649,22 @@ Unit AoptObj;
<code> <code>
lab_2: lab_2:
} }
hp3:=hp1;
if hp1.typ = ait_label then if hp1.typ = ait_label then
SkipLabels(hp1,hp1); SkipLabels(hp1,hp1);
if (tai(hp1).typ=ait_instruction) and if (tai(hp1).typ=ait_instruction) and
IsJumpToLabelUncond(taicpu(hp1)) and IsJumpToLabelUncond(taicpu(hp1)) and
GetNextInstruction(hp1, hp2) and GetNextInstruction(hp1, hp2) and
IsJumpToLabel(taicpu(p)) and IsJumpToLabel(taicpu(p)) and
FindLabel(tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol), hp2) then FindLabel(tasmlabel(JumpTargetOp(taicpu(p))^.ref^.symbol), hp2) and
{ prevent removal of infinite loop from
jmp<cond> lab_1
lab_2:
jmp lab2
..
lab_1:
}
not FindLabel(tasmlabel(JumpTargetOp(taicpu(hp1))^.ref^.symbol), hp3) then
begin begin
if (taicpu(p).opcode=aopt_condjmp) if (taicpu(p).opcode=aopt_condjmp)
{$if defined(arm) or defined(aarch64)} {$if defined(arm) or defined(aarch64)}