diff --git a/compiler/optdeadstore.pas b/compiler/optdeadstore.pas index 7cd7d8ca25..2c325f0213 100644 --- a/compiler/optdeadstore.pas +++ b/compiler/optdeadstore.pas @@ -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;