Преглед изворни кода

* fix life information propagation for while loops, resolves #39971
* warnings/errors fixed which are caused by the new life information propagation
+ test

florian пре 2 година
родитељ
комит
3fa77a4f62

+ 2 - 1
compiler/dbgdwarf.pas

@@ -3486,7 +3486,8 @@ implementation
         prevline := 1;
         prevfileidx := 1;
         prevlabel := nil;
-        nolineinfolevel:=0;
+        nolineinfolevel := 0;
+        hpend := nil;
         while assigned(hp) do
           begin
             case hp.typ of

+ 1 - 1
compiler/ngtcon.pas

@@ -1675,13 +1675,13 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
         srsym:=get_next_varsym(def,symlist,symidx);
         recsym := nil;
         startoffset:=curoffset;
+        error := false;
         while token<>_RKLAMMER do
           begin
             s:=pattern;
             sorg:=orgpattern;
             consume(_ID);
             consume(_COLON);
-            error := false;
             recsym := tsym(def.symtable.Find(s));
             if not assigned(recsym) then
               begin

+ 6 - 1
compiler/optdfa.pas

@@ -289,7 +289,12 @@ unit optdfa;
                 { for while loops, node use set is included at the beginning of loop }
                 l:=twhilerepeatnode(node).right.optinfo^.life;
                 if lnf_testatbegin in twhilerepeatnode(node).loopflags then
-                  DFASetIncludeSet(l,node.optinfo^.use);
+                  begin
+                    DFASetIncludeSet(l,node.optinfo^.use);
+                    { ... loop body could be skipped, so include life info of the successsor node }
+                    if assigned(node.successor) then
+                      DFASetIncludeSet(l,node.successor.optinfo^.life);
+                  end;
 
                 UpdateLifeInfo(node,l);
 

+ 1 - 0
compiler/pgenutil.pas

@@ -505,6 +505,7 @@ uses
                             for j:=0 to formalobjdef.implementedinterfaces.count-1 do
                               begin
                                 objdef:=paraobjdef;
+                                intffound:=false;
                                 while assigned(objdef) do
                                   begin
                                     intffound:=assigned(

+ 1 - 0
compiler/systems/t_bsd.pas

@@ -69,6 +69,7 @@ function ModulesLinkToLibc:boolean;
 var
   hp: tmodule;
 begin
+  result:=false;
   { This is called very early, ImportLibraryList is not yet merged into linkothersharedlibs.
     The former contains library names qualified with prefix and suffix (coming from
     "external 'c' name 'foo' declarations), the latter contains raw names (from "$linklib c"

+ 2 - 1
compiler/systems/t_linux.pas

@@ -334,11 +334,12 @@ function ModulesLinkToLibc:boolean;
 var
   hp: tmodule;
 begin
+  result:=false;
   { This is called very early, ImportLibraryList is not yet merged into linkothersharedlibs.
     The former contains library names qualified with prefix and suffix (coming from
     "external 'c' name 'foo' declarations), the latter contains raw names (from "$linklib c"
     directives). }
-  hp:=tmodule(loaded_units.first);
+  hp:=tmodule(loaded_units.first);  
   while assigned(hp) do
     begin
       result:=Assigned(hp.ImportLibraryList.find(target_info.sharedClibprefix+'c'+target_info.sharedClibext));

+ 1 - 0
compiler/systems/t_win.pas

@@ -136,6 +136,7 @@ implementation
     begin
       if target_info.system=system_i386_win32 then
         begin
+          linkcygwin := false;
           hp:=tmodule(loaded_units.first);
           while assigned(hp) do
            begin

+ 1 - 0
tests/test/opt/tdfa2.pp

@@ -37,6 +37,7 @@ var
   c1: Word;
 begin
   counter:=0;  
+  c1 := 0;
   while counter<len do
   begin
     c1 := ord(s1[counter]);

+ 19 - 0
tests/webtbs/tw39971.pp

@@ -0,0 +1,19 @@
+{ %opt=-O4 -Oodeadstore -S2 }
+function FileSizeFractionalPart(sz: uint64): uint32;
+var
+	fr: uint32;
+begin
+	fr := 0;
+	while sz > 1000 do
+	begin
+		fr := sz mod 1024;
+		sz := sz div 1024;
+	end;
+	result := fr;
+end;
+
+begin
+	writeln(FileSizeFractionalPart(12));
+    if FileSizeFractionalPart(12)<>0 then
+      halt(1);
+end.