|
@@ -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;
|
|
|
|
- foreachnodestatic(pm_postprocess, rootnode, @deadstoreelim, @changed);
|
|
|
|
|
|
+ writeln('******************** Tree after deadstore elimination **********************');
|
|
|
|
+ printnode(rootnode);
|
|
|
|
+ writeln('****************************************************************************');
|
|
end;
|
|
end;
|
|
|
|
+{$endif DEBUG_DEADSTORE}
|
|
result:=rootnode;
|
|
result:=rootnode;
|
|
end;
|
|
end;
|
|
|
|
|