* skip instructions containing a reference with a segment prefix (fixes

mantis #18113)

git-svn-id: trunk@16619 -
This commit is contained in:
Jonas Maebe 2010-12-23 15:24:29 +00:00
parent c8115921f1
commit d10f46ec59
3 changed files with 57 additions and 0 deletions

1
.gitattributes vendored
View File

@ -10907,6 +10907,7 @@ tests/webtbs/tw18075.pp svneol=native#text/pascal
tests/webtbs/tw18082.pp svneol=native#text/plain
tests/webtbs/tw18085.pp svneol=native#text/pascal
tests/webtbs/tw18086.pp svneol=native#text/pascal
tests/webtbs/tw18113.pp svneol=native#text/plain
tests/webtbs/tw18123.pp svneol=native#text/pascal
tests/webtbs/tw18127.pp svneol=native#text/pascal
tests/webtbs/tw18131.pp svneol=native#text/pascal

View File

@ -128,6 +128,20 @@ begin
end;
{ returns true if p contains a memory operand with a segment set }
function InsContainsSegRef(p: taicpu): boolean;
var
i: longint;
begin
result:=true;
for i:=0 to p.opercnt-1 do
if (p.oper[i]^.typ=top_ref) and
(p.oper[i]^.ref^.segment<>NR_NO) then
exit;
result:=false;
end;
procedure PrePeepHoleOpts(asml: TAsmList; BlockStart, BlockEnd: tai);
var
p,hp1: tai;
@ -140,6 +154,11 @@ begin
case p.Typ Of
Ait_Instruction:
begin
if InsContainsSegRef(taicpu(p)) then
begin
p := tai(p.next);
continue;
end;
case taicpu(p).opcode Of
A_IMUL:
{changes certain "imul const, %reg"'s to lea sequences}
@ -606,6 +625,11 @@ begin
case p.Typ Of
ait_instruction:
begin
if InsContainsSegRef(taicpu(p)) then
begin
p := tai(p.next);
continue;
end;
{ Handle Jmp Optimizations }
if taicpu(p).is_jmp then
begin
@ -1779,6 +1803,11 @@ begin
case p.Typ Of
Ait_Instruction:
begin
if InsContainsSegRef(taicpu(p)) then
begin
p := tai(p.next);
continue;
end;
case taicpu(p).opcode Of
A_Jcc:
begin
@ -2065,6 +2094,11 @@ begin
case p.Typ Of
Ait_Instruction:
begin
if InsContainsSegRef(taicpu(p)) then
begin
p := tai(p.next);
continue;
end;
case taicpu(p).opcode Of
A_CALL:
if (current_settings.optimizecputype < cpu_Pentium2) and

22
tests/webtbs/tw18113.pp Normal file
View File

@ -0,0 +1,22 @@
{ %target=go32v2 }
{ %interactive }
{ check whether this program writes '*' }
Procedure Confuse;
begin
end;
Procedure TestBug(chr:word);
begin
Confuse; {if you comment it, everything is fine even in Level 2}
Mem[$B800:0]:=byte(chr);
end;
begin
writeln(#13#10#13#10);
TestBug(42); {should print '*'}
readln;
end.