Przeglądaj źródła

* fixed webbug 1323

Jonas Maebe 24 lat temu
rodzic
commit
e753af622e
3 zmienionych plików z 66 dodań i 15 usunięć
  1. 14 11
      compiler/i386/csopt386.pas
  2. 46 2
      compiler/i386/n386flw.pas
  3. 6 2
      compiler/i386/rropt386.pas

+ 14 - 11
compiler/i386/csopt386.pas

@@ -1052,7 +1052,8 @@ begin
     begin
       tmpResult :=
         getNextInstruction(endP,endP) and
-        (endp.typ = ait_instruction);
+        (endp.typ = ait_instruction) and
+        not(Taicpu(endp).is_jmp);
       if tmpresult and not assigned(endp.optInfo) then
         begin
 {          hp := Tai_asm_comment.Create(strpnew('next no optinfo'));
@@ -1111,8 +1112,8 @@ begin
             not(removeLast) and
             not(newRegModified and orgRegRead) and
 (*            (orgRegCanBeModified or not(newRegModified)) and *)
-            (endp.typ = ait_instruction) and
-            not(Taicpu(endp).is_jmp) and
+(*          already check at the top
+            (endp.typ = ait_instruction) and  *)
             NoHardCodedRegs(Taicpu(endP),orgReg,newReg) and
             RegSizesOk(orgReg,newReg,Taicpu(endP)) and
             not RegModifiedByInstruction(orgReg,endP);
@@ -1456,25 +1457,24 @@ Begin
                                                       regCounter,hp3,
                                                       PTaiProp(PrevSeq.optInfo)^.Regs[regCounter],true,hp5) then
                                                begin
-                                                 hp3 := Tai_Marker.Create(NoPropInfoEnd);
-                                                 InsertLLItem(AsmL, prevSeq, Tai(prevSeq.next), hp3);
+                                                 hp3 := Tai_Marker.Create(NoPropInfoStart);
+                                                 InsertLLItem(AsmL, prevSeq_next.previous,Tai(prevSeq_next), hp3);
                                                  hp5 := Taicpu.Op_Reg_Reg(A_MOV, S_L,
                                                                          {old reg          new reg}
                                                        RegInfo.New2OldReg[RegCounter], RegCounter);
                                                  new(pTaiprop(hp5.optinfo));
                                                  pTaiprop(hp5.optinfo)^ := pTaiprop(prevSeq_next.optinfo)^;
                                                  pTaiprop(hp5.optinfo)^.canBeRemoved := false;
-                                                 InsertLLItem(AsmL, prevSeq, Tai(prevSeq.next), hp5);
-                                                 hp3 := Tai_Marker.Create(NoPropInfoStart);
-                                                 InsertLLItem(AsmL, prevSeq, Tai(prevSeq.next), hp3);
+                                                 InsertLLItem(AsmL, prevSeq_next.previous, Tai(prevSeq_next), hp5);
+                                                 hp3 := Tai_Marker.Create(NoPropInfoEnd);
+                                                 InsertLLItem(AsmL, prevSeq_next.previous, Tai(prevSeq_next), hp3);
                                                  { adjusts states in previous instruction so that it will  }
                                                  { definitely be different from the previous or next state }
                                                  incstate(pTaiprop(hp5.optinfo)^.
                                                    regs[RegInfo.New2OldReg[RegCounter]].rstate,20);
                                                  incstate(pTaiprop(hp5.optinfo)^.
                                                    regs[regCounter].wstate,20);
-                                                 updateState(RegInfo.New2OldReg[RegCounter],
-                                                   hp5);
+                                                 updateState(RegInfo.New2OldReg[RegCounter],hp5);
                                                end
                                            End
                                          Else
@@ -1702,7 +1702,10 @@ End.
 
 {
   $Log$
-  Revision 1.10  2000-12-25 00:07:31  peter
+  Revision 1.11  2001-01-06 23:35:05  jonas
+    * fixed webbug 1323
+
+  Revision 1.10  2000/12/25 00:07:31  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
 

+ 46 - 2
compiler/i386/n386flw.pas

@@ -445,12 +445,30 @@ implementation
 *****************************************************************************}
 
     procedure ti386exitnode.pass_2;
+
       var
-         is_mem : boolean;
          {op : tasmop;
          s : topsize;}
          otlabel,oflabel : pasmlabel;
          r : preference;
+         is_mem,
+         allocated_eax,
+         allocated_edx: boolean;
+
+      procedure cleanleft;
+        begin
+          if is_mem then
+            begin
+              del_reference(left.location.reference);
+              ungetiftemp(left.location.reference);
+            end
+          else
+            begin
+              ungetregister(left.location.register);
+              if left.location.registerhigh <> R_NO then
+                ungetregister(left.location.registerhigh);
+            end;
+        end;
 
       label
          do_jmp;
@@ -466,6 +484,8 @@ implementation
            end
          else
            begin
+              allocated_eax := false;
+              allocated_edx := false;
               otlabel:=truelabel;
               oflabel:=falselabel;
               getlabel(truelabel);
@@ -478,10 +498,14 @@ implementation
            LOC_CREGISTER,
             LOC_REGISTER : is_mem:=false;
                LOC_FLAGS : begin
+                             exprasmlist.concat(tairegalloc.alloc(R_EAX));
+                             allocated_eax := true;
                              emit_flag2reg(left.location.resflags,R_AL);
                              goto do_jmp;
                            end;
                 LOC_JUMP : begin
+                             exprasmlist.concat(tairegalloc.alloc(R_EAX));
+                             allocated_eax := true;
                              emitlab(truelabel);
                              emit_const_reg(A_MOV,S_B,1,R_AL);
                              emitjmp(C_None,aktexit2label);
@@ -495,6 +519,9 @@ implementation
               case procinfo^.returntype.def^.deftype of
            pointerdef,
            procvardef : begin
+                          cleanleft;
+                          exprasmlist.concat(tairegalloc.alloc(R_EAX));
+                          allocated_eax := true;
                           if is_mem then
                             emit_ref_reg(A_MOV,S_L,
                               newreference(left.location.reference),R_EAX)
@@ -503,8 +530,11 @@ implementation
                               left.location.register,R_EAX);
                         end;
              floatdef : begin
+                          cleanleft;
                           if pfloatdef(procinfo^.returntype.def)^.typ=f32bit then
                            begin
+                             exprasmlist.concat(tairegalloc.alloc(R_EAX));
+                             allocated_eax := true;
                              if is_mem then
                                emit_ref_reg(A_MOV,S_L,
                                  newreference(left.location.reference),R_EAX)
@@ -521,6 +551,9 @@ implementation
               { it can be anything shorter than 4 bytes PM
               this caused form bug 711 }
                        begin
+                          cleanleft;
+                          exprasmlist.concat(tairegalloc.alloc(R_EAX));
+                          allocated_eax := true;
                           case procinfo^.returntype.def^.size of
                            { it can be a qword/int64 too ... }
                            8 : if is_mem then
@@ -529,11 +562,15 @@ implementation
                                       newreference(left.location.reference),R_EAX);
                                     r:=newreference(left.location.reference);
                                     inc(r^.offset,4);
+                                    exprasmlist.concat(tairegalloc.alloc(R_EDX));
+                                    allocated_edx := true;
                                     emit_ref_reg(A_MOV,S_L,r,R_EDX);
                                  end
                                else
                                  begin
                                     emit_reg_reg(A_MOV,S_L,left.location.registerlow,R_EAX);
+                                    exprasmlist.concat(tairegalloc.alloc(R_EDX));
+                                    allocated_edx := true;
                                     emit_reg_reg(A_MOV,S_L,left.location.registerhigh,R_EDX);
                                  end;
                           { if its 3 bytes only we can still
@@ -561,6 +598,10 @@ do_jmp:
               truelabel:=otlabel;
               falselabel:=oflabel;
               emitjmp(C_None,aktexit2label);
+              if allocated_eax then
+                exprasmlist.concat(tairegalloc.dealloc(R_EAX));
+              if allocated_edx then
+                exprasmlist.concat(tairegalloc.dealloc(R_EDX));
            end
          else
             emitjmp(C_None,aktexitlabel);
@@ -1340,7 +1381,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.6  2001-01-05 17:36:58  florian
+  Revision 1.7  2001-01-06 23:35:05  jonas
+    * fixed webbug 1323
+
+  Revision 1.6  2001/01/05 17:36:58  florian
   * the info about exception frames is stored now on the stack
   instead on the heap
 

+ 6 - 2
compiler/i386/rropt386.pas

@@ -250,7 +250,8 @@ begin
             (endp.typ <> ait_label) and
             ((not isInstruction) or
              (NoHardCodedRegs(Taicpu(endP),reg1,reg2) and
-               RegSizesOk(reg1,reg2,Taicpu(endP))));
+              RegSizesOk(reg1,reg2,Taicpu(endP)) and
+              (Taicpu(endp).opcode <> A_JMP)));
         end;
     end;
 
@@ -334,7 +335,10 @@ End.
 
 {
   $Log$
-  Revision 1.5  2000-12-25 00:07:34  peter
+  Revision 1.6  2001-01-06 23:35:06  jonas
+    * fixed webbug 1323
+
+  Revision 1.5  2000/12/25 00:07:34  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)