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