mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 13:59:29 +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,
|
||||
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;
|
||||
|
||||
|
@ -589,6 +589,9 @@ interface
|
||||
|
||||
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
|
||||
the value of another temp, that other temp was not freed because the
|
||||
ti_const flag was set }
|
||||
|
@ -284,6 +284,7 @@ unit optcse;
|
||||
nodes : tblocknode;
|
||||
creates,
|
||||
statements : tstatementnode;
|
||||
deletetemp : ttempdeletenode;
|
||||
hp : ttempcreatenode;
|
||||
addrstored : boolean;
|
||||
hp2 : tnode;
|
||||
@ -414,6 +415,12 @@ unit optcse;
|
||||
tnode(templist[i]).fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
||||
|
||||
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 }
|
||||
creates.fileinfo:=tnode(lists.nodelist[i]).fileinfo;
|
||||
|
||||
@ -505,16 +512,35 @@ unit optcse;
|
||||
|
||||
|
||||
function do_optcse(var rootnode : tnode) : tnode;
|
||||
var
|
||||
deletes,
|
||||
statements : tstatementnode;
|
||||
deleteblock,
|
||||
rootblock : tblocknode;
|
||||
begin
|
||||
{$ifdef csedebug}
|
||||
writeln('====================================================================================');
|
||||
writeln('CSE optimization pass started');
|
||||
writeln('====================================================================================');
|
||||
printnode(rootnode);
|
||||
writeln('====================================================================================');
|
||||
writeln;
|
||||
writeln('====================================================================================');
|
||||
writeln('CSE optimization pass started');
|
||||
writeln('====================================================================================');
|
||||
printnode(rootnode);
|
||||
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}
|
||||
foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,nil);
|
||||
result:=nil;
|
||||
end;
|
||||
|
||||
|
@ -31,9 +31,6 @@ interface
|
||||
symdef,procinfo,optdfa;
|
||||
|
||||
type
|
||||
|
||||
{ tcgprocinfo }
|
||||
|
||||
tcgprocinfo = class(tprocinfo)
|
||||
private
|
||||
procedure CreateInlineInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user