Browse Source

* fix for crash when the first instruction of a sequence that gets
optimized is removed (this situation can't occur aymore now)

Jonas Maebe 26 years ago
parent
commit
05acbe4077
2 changed files with 20 additions and 10 deletions
  1. 11 6
      compiler/aopt386.pas
  2. 9 4
      compiler/daopt386.pas

+ 11 - 6
compiler/aopt386.pas

@@ -39,7 +39,7 @@ Uses
 
 
 Procedure Optimize(AsmL: PAasmOutput);
-Var BlockStart, BlockEnd: Pai;
+Var BlockStart, BlockEnd, HP: Pai;
 Begin
 {setup labeltable, always necessary}
   BlockStart := Pai(AsmL^.First);
@@ -72,10 +72,11 @@ Begin
           While GetNextInstruction(BlockStart, BlockStart) And
                 ((BlockStart^.Typ <> Ait_Marker) Or
                  (Pai_Marker(Blockstart)^.Kind <> AsmBlockEnd)) Do;
-          If GetNextInstruction(BlockStart, BlockStart) And
-             ((BlockStart^.typ <> ait_Marker) Or
-             (Pai_Marker(BlockStart)^.Kind <> AsmBlockStart)) Then
-            BlockEnd := DFAPass1(AsmL, BlockStart);
+          If GetNextInstruction(BlockStart, HP) And
+             ((HP^.typ <> ait_Marker) Or
+             (Pai_Marker(HP)^.Kind <> AsmBlockStart)) Then
+            BlockEnd := DFAPass1(AsmL, BlockStart)
+          Else BlockStart := HP;
         End
    End;
 End;
@@ -84,7 +85,11 @@ End.
 
 {
  $Log$
- Revision 1.26  1999-03-31 13:55:03  peter
+ Revision 1.27  1999-04-18 17:57:17  jonas
+   * fix for crash when the first instruction of a sequence that gets
+     optimized is removed (this situation can't occur aymore now)
+
+ Revision 1.26  1999/03/31 13:55:03  peter
    * assembler inlining working for ag386bin
 
  Revision 1.25  1998/12/29 19:58:27  jonas

+ 9 - 4
compiler/daopt386.pas

@@ -1237,7 +1237,9 @@ Var OldP: Pai;
 Begin
   Repeat
     OldP := P;
-    If (P^.typ in SkipInstr) Then
+    If (P^.typ in SkipInstr) Or
+       ((P^.typ = ait_marker) And
+        (Pai_Marker(P)^.Kind = AsmBlockEnd)) Then
       GetNextInstruction(P, P)
     Else If ((P^.Typ = Ait_Marker) And
         (Pai_Marker(P)^.Kind = NoPropInfoStart)) Then
@@ -1759,8 +1761,7 @@ Begin
   p := BlockStart;
   UsedRegs := [];
   UpdateUsedregs(UsedRegs, p);
-  If (BlockStart^.typ in SkipInstr) Then
-    GetNextInstruction(p, p);
+  SkipHead(P);
   BlockStart := p;
   InstrCnt := 1;
   FillChar(NrOfInstrSinceLastMod, SizeOf(NrOfInstrSinceLastMod), 0);
@@ -2286,7 +2287,11 @@ End.
 
 {
  $Log$
- Revision 1.43  1999-04-17 22:16:59  pierre
+ Revision 1.44  1999-04-18 17:57:19  jonas
+   * fix for crash when the first instruction of a sequence that gets
+     optimized is removed (this situation can't occur aymore now)
+
+ Revision 1.43  1999/04/17 22:16:59  pierre
    * ifdef USE_OP3 released (changed into ifndef NO_OP3)
    * SHRD and SHLD first operand (ATT syntax) can only be CL reg or immediate const