2
0
Эх сурвалжийг харах

* fixes to deadstore optimization

git-svn-id: trunk@49117 -
florian 4 жил өмнө
parent
commit
08817f1aed

+ 16 - 3
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;