Forráskód Böngészése

* fixed webtbs/tw4388: properly process regalloc info coming right after
a tai_marker of type asmblockend, and fixed removal of too many
tai_regallocs in some cases (daopt386.pas)
* some preventive fixes to make sure the optimizer doesn't start optimizing
inside inline assembler blocks (csopt386.pas)

git-svn-id: trunk@1284 -

Jonas Maebe 20 éve
szülő
commit
c3a5f88a7b
2 módosított fájl, 15 hozzáadás és 9 törlés
  1. 8 5
      compiler/i386/csopt386.pas
  2. 7 4
      compiler/i386/daopt386.pas

+ 8 - 5
compiler/i386/csopt386.pas

@@ -518,9 +518,10 @@ begin {CheckSequence}
             flagResultsNeeded := not instrReadsFlags(hp3);
           if not flagResultsNeeded then
             flagResultsNeeded := ptaiprop(hp3.optinfo)^.FlagsUsed;
-          GetNextInstruction(hp2, hp2);
-          GetNextInstruction(hp3, hp3);
           inc(Found);
+          if not GetNextInstruction(hp2, hp2) or
+             not GetNextInstruction(hp3, hp3) then
+            break;
         end;
 
       for regCounter2 := RS_EAX to RS_EDI do
@@ -890,8 +891,9 @@ begin
   if (newrstate = ptaiprop(p.optinfo)^.Regs[supreg].rState) then
     begin
       incstate(ptaiprop(p.optinfo)^.regs[supreg].rstate,63);
-      if getnextinstruction(p,hp) and
-         (ptaiprop(hp.optinfo)^.regs[supreg].rstate = ptaiprop(p.optinfo)^.regs[supreg].rstate) then
+      if not getnextinstruction(p,hp) then
+        exit;
+      if (ptaiprop(hp.optinfo)^.regs[supreg].rstate = ptaiprop(p.optinfo)^.regs[supreg].rstate) then
         internalerror(2004122710);
      end;
   dummyregs := [supreg];
@@ -1367,7 +1369,8 @@ begin
       replaceReg := true;
       returnEndP := endP;
 
-      getNextInstruction(p,hp);
+      if not getNextInstruction(p,hp) then
+        exit;
       stateChanged := false;
       while hp <> endP do
         begin

+ 7 - 4
compiler/i386/daopt386.pas

@@ -190,7 +190,7 @@ function writeDestroysContents(const op: toper; supreg: tsuperregister; size: tc
 
 function GetNextInstruction(Current: tai; var Next: tai): Boolean;
 function GetLastInstruction(Current: tai; var Last: tai): Boolean;
-    procedure SkipHead(var p: tai);
+procedure SkipHead(var p: tai);
 function labelCanBeSkipped(p: tai_label): boolean;
 
 procedure RemoveLastDeallocForFuncRes(asmL: TAAsmOutput; p: tai);
@@ -1129,7 +1129,9 @@ begin
     while assigned(p) and
           ((p.typ in (SkipInstr - [ait_RegAlloc])) or
            ((p.typ = ait_label) and
-            labelCanBeSkipped(tai_label(p)))) Do
+            labelCanBeSkipped(tai_label(p))) or
+           ((p.typ = ait_marker) and 
+            (tai_Marker(p).Kind in [AsmBlockend,inlinestart,inlineend]))) do
          p := tai(p.next);
     while assigned(p) and
           (p.typ=ait_RegAlloc) Do
@@ -2094,7 +2096,7 @@ begin
                   exclude(usedregs, supreg);
                   hp1 := p;
                   hp2 := nil;
-                  while not(findregalloc(getsupreg(tai_regalloc(p).reg), tai(hp1.next),ra_alloc)) and
+                  while not(findregalloc(supreg,tai(hp1.next),ra_alloc)) and
                         getnextinstruction(hp1, hp1) and
                         regininstruction(getsupreg(tai_regalloc(p).reg), hp1) Do
                     hp2 := hp1;
@@ -2112,7 +2114,8 @@ begin
                       list.remove(p);
                       p.free;
                       p := hp1;
-                      include(usedregs,supreg);
+//                      don't include here, since then the allocation will be removed when it's processed
+//                      include(usedregs,supreg);
                     end;
                 end;
              end;