mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 06:32:03 +02:00
* the temp. locations created by cse were not properly cleanup up, this patch fixes this
git-svn-id: trunk@38624 -
This commit is contained in:
parent
24ff8b07e4
commit
1497b64804
@ -163,7 +163,13 @@ interface
|
|||||||
{ the temp. needs no final sync instruction if it is located in a register,
|
{ the temp. needs no final sync instruction if it is located in a register,
|
||||||
so there are no loops involved in the usage of the temp.
|
so there are no loops involved in the usage of the temp.
|
||||||
}
|
}
|
||||||
ti_no_final_regsync
|
ti_no_final_regsync,
|
||||||
|
{ this applied only to delete nodes: the single purpose of the temp. delete node is to clean up memory. In case
|
||||||
|
of cse it might happen that the tempcreate node is optimized away so tempinfo is never initialized properly but
|
||||||
|
the allocated memory must be disposed
|
||||||
|
If a temp. node has this flag set, the life time of the temp. data must be determined by reg. life, the temp.
|
||||||
|
location (in the sense of stack space/register) is never release }
|
||||||
|
ti_cleanup_only
|
||||||
);
|
);
|
||||||
ttempinfoflags = set of ttempinfoflag;
|
ttempinfoflags = set of ttempinfoflag;
|
||||||
|
|
||||||
|
@ -589,6 +589,9 @@ interface
|
|||||||
|
|
||||||
location_reset(location,LOC_VOID,OS_NO);
|
location_reset(location,LOC_VOID,OS_NO);
|
||||||
|
|
||||||
|
if ti_cleanup_only in tempflags then
|
||||||
|
exit;
|
||||||
|
|
||||||
{ see comments at ti_const declaration: if we initialised this temp with
|
{ see comments at ti_const declaration: if we initialised this temp with
|
||||||
the value of another temp, that other temp was not freed because the
|
the value of another temp, that other temp was not freed because the
|
||||||
ti_const flag was set }
|
ti_const flag was set }
|
||||||
|
@ -284,6 +284,7 @@ unit optcse;
|
|||||||
nodes : tblocknode;
|
nodes : tblocknode;
|
||||||
creates,
|
creates,
|
||||||
statements : tstatementnode;
|
statements : tstatementnode;
|
||||||
|
deletetemp : ttempdeletenode;
|
||||||
hp : ttempcreatenode;
|
hp : ttempcreatenode;
|
||||||
addrstored : boolean;
|
addrstored : boolean;
|
||||||
hp2 : tnode;
|
hp2 : tnode;
|
||||||
@ -414,6 +415,12 @@ unit optcse;
|
|||||||
tnode(templist[i]).fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
tnode(templist[i]).fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
||||||
|
|
||||||
addstatement(creates,tnode(templist[i]));
|
addstatement(creates,tnode(templist[i]));
|
||||||
|
|
||||||
|
{ the delete node has no semantic use yet, it is just used to clean up memory }
|
||||||
|
deletetemp:=ctempdeletenode.create(ttempcreatenode(templist[i]));
|
||||||
|
deletetemp.includetempflag(ti_cleanup_only);
|
||||||
|
addstatement(tstatementnode(arg^),deletetemp);
|
||||||
|
|
||||||
{ make debugging easier and set temp. location to the original location }
|
{ make debugging easier and set temp. location to the original location }
|
||||||
creates.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
creates.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
||||||
|
|
||||||
@ -505,16 +512,35 @@ unit optcse;
|
|||||||
|
|
||||||
|
|
||||||
function do_optcse(var rootnode : tnode) : tnode;
|
function do_optcse(var rootnode : tnode) : tnode;
|
||||||
|
var
|
||||||
|
deletes,
|
||||||
|
statements : tstatementnode;
|
||||||
|
deleteblock,
|
||||||
|
rootblock : tblocknode;
|
||||||
begin
|
begin
|
||||||
{$ifdef csedebug}
|
{$ifdef csedebug}
|
||||||
writeln('====================================================================================');
|
writeln('====================================================================================');
|
||||||
writeln('CSE optimization pass started');
|
writeln('CSE optimization pass started');
|
||||||
writeln('====================================================================================');
|
writeln('====================================================================================');
|
||||||
printnode(rootnode);
|
printnode(rootnode);
|
||||||
writeln('====================================================================================');
|
writeln('====================================================================================');
|
||||||
writeln;
|
writeln;
|
||||||
|
{$endif csedebug}
|
||||||
|
deleteblock:=internalstatements(deletes);
|
||||||
|
foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,@deletes);
|
||||||
|
rootblock:=internalstatements(statements);
|
||||||
|
addstatement(statements,rootnode);
|
||||||
|
addstatement(statements,deleteblock);
|
||||||
|
rootnode:=rootblock;
|
||||||
|
do_firstpass(rootnode);
|
||||||
|
{$ifdef csedebug}
|
||||||
|
writeln('====================================================================================');
|
||||||
|
writeln('CSE optimization result');
|
||||||
|
writeln('====================================================================================');
|
||||||
|
printnode(rootnode);
|
||||||
|
writeln('====================================================================================');
|
||||||
|
writeln;
|
||||||
{$endif csedebug}
|
{$endif csedebug}
|
||||||
foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,nil);
|
|
||||||
result:=nil;
|
result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -31,9 +31,6 @@ interface
|
|||||||
symdef,procinfo,optdfa;
|
symdef,procinfo,optdfa;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ tcgprocinfo }
|
|
||||||
|
|
||||||
tcgprocinfo = class(tprocinfo)
|
tcgprocinfo = class(tprocinfo)
|
||||||
private
|
private
|
||||||
procedure CreateInlineInfo;
|
procedure CreateInlineInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user