* fix life information propagation for while loops, resolves #39971

* warnings/errors fixed which are caused by the new life information propagation
  + test
This commit is contained in:
florian 2022-10-24 22:10:34 +02:00
parent e63cc73cfa
commit 3fa77a4f62
9 changed files with 34 additions and 4 deletions

View File

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

View File

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

View File

@ -289,7 +289,12 @@ unit optdfa;
{ for while loops, node use set is included at the beginning of loop } { for while loops, node use set is included at the beginning of loop }
l:=twhilerepeatnode(node).right.optinfo^.life; l:=twhilerepeatnode(node).right.optinfo^.life;
if lnf_testatbegin in twhilerepeatnode(node).loopflags then 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); UpdateLifeInfo(node,l);

View File

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

View File

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

View File

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

View File

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

View File

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

19
tests/webtbs/tw39971.pp Normal file
View File

@ -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.