* fixes to deadstore optimization

git-svn-id: trunk@49117 -
This commit is contained in:
florian 2021-04-03 21:28:09 +00:00
parent 1edc9cd01b
commit 08817f1aed

View File

@ -24,6 +24,7 @@ unit optdeadstore;
{$i fpcdefs.inc} {$i fpcdefs.inc}
{ $define DEBUG_DEADSTORE} { $define DEBUG_DEADSTORE}
{ $define EXTDEBUG_DEADSTORE}
interface interface
@ -71,7 +72,8 @@ unit optdeadstore;
(tparavarsym(tloadnode(a.left).symtableentry).varspez in [vs_const,vs_value])) or (tparavarsym(tloadnode(a.left).symtableentry).varspez in [vs_const,vs_value])) or
((tloadnode(a.left).symtableentry.typ=staticvarsym) and ((tloadnode(a.left).symtableentry.typ=staticvarsym) and
(tloadnode(a.left).symtable.symtabletype=staticsymtable) and (tloadnode(a.left).symtable.symtabletype=staticsymtable) and
(current_procinfo.procdef.proctypeoption<>potype_unitinit) (current_procinfo.procdef.proctypeoption<>potype_unitinit) and
not(vsa_different_scope in tstaticvarsym(tloadnode(a.left).symtableentry).varsymaccess)
) )
) and ) and
((a.right.nodetype in [niln,stringconstn,pointerconstn,setconstn,guidconstn]) or ((a.right.nodetype in [niln,stringconstn,pointerconstn,setconstn,guidconstn]) or
@ -108,13 +110,24 @@ unit optdeadstore;
var var
changed: boolean; changed: boolean;
begin begin
{$ifdef EXTDEBUG_DEADSTORE}
writeln('******************* Tree before deadstore elimination **********************');
printnode(rootnode);
writeln('****************************************************************************');
{$endif EXTDEBUG_DEADSTORE}
if not(pi_dfaavailable in current_procinfo.flags) then if not(pi_dfaavailable in current_procinfo.flags) then
internalerror(2013110201); internalerror(2013110201);
changed:=false;
if not current_procinfo.has_nestedprocs then if not current_procinfo.has_nestedprocs then
foreachnodestatic(pm_postprocess, rootnode, @deadstoreelim, @changed);
{$ifdef DEBUG_DEADSTORE}
if changed then
begin begin
changed:=false; writeln('******************** Tree after deadstore elimination **********************');
foreachnodestatic(pm_postprocess, rootnode, @deadstoreelim, @changed); printnode(rootnode);
writeln('****************************************************************************');
end; end;
{$endif DEBUG_DEADSTORE}
result:=rootnode; result:=rootnode;
end; end;