Browse Source

- revert r47208
* properly fix the internalerror it hid: only replace the local symbols
migrated to the parentfpstruct right before generating debug information,
so that internally generated self/result loads during optimisation passes
don't get confused by the replacement absolutevarsyms (those are normally
never encountered during optimisation, as regular absolutevarsyms are
replaced during parsing)

git-svn-id: trunk@47855 -

Jonas Maebe 4 years ago
parent
commit
5d51a788f7
3 changed files with 15 additions and 14 deletions
  1. 0 6
      compiler/nutils.pas
  2. 2 1
      compiler/optdfa.pas
  3. 13 7
      compiler/psub.pas

+ 0 - 6
compiler/nutils.pas

@@ -569,12 +569,6 @@ implementation
        begin
        begin
         result:=nil;
         result:=nil;
         srsym:=get_local_or_para_sym('result');
         srsym:=get_local_or_para_sym('result');
-        if not assigned(srsym) then
-          begin
-            pd:=current_procinfo.procdef;
-            if assigned(pd.procsym) then
-              srsym:=get_local_or_para_sym(pd.procsym.name);
-          end;
         if assigned(srsym) then
         if assigned(srsym) then
           result:=cloadnode.create(srsym,srsym.owner)
           result:=cloadnode.create(srsym,srsym.owner)
         else
         else

+ 2 - 1
compiler/optdfa.pas

@@ -714,7 +714,8 @@ unit optdfa;
                    ((vo_is_funcret in sym.varoptions) and
                    ((vo_is_funcret in sym.varoptions) and
                     (current_procinfo.procdef.parast.symtablelevel=sym.owner.symtablelevel)
                     (current_procinfo.procdef.parast.symtablelevel=sym.owner.symtablelevel)
                    )
                    )
-                  ) and not(vo_is_external in sym.varoptions)
+                  ) and not(vo_is_external in sym.varoptions) and
+                  not sym.inparentfpstruct;
         end;
         end;
 
 
       var
       var

+ 13 - 7
compiler/psub.pas

@@ -369,12 +369,6 @@ implementation
 
 
         if assigned(current_procinfo.procdef.parentfpstruct) then
         if assigned(current_procinfo.procdef.parentfpstruct) then
          begin
          begin
-           { we only do this after the code has been parsed because
-             otherwise for-loop counters moved to the struct cause
-             errors; we still do it nevertheless to prevent false
-             "unused" symbols warnings and to assist debug info
-             generation }
-           redirect_parentfpstruct_local_syms(current_procinfo.procdef);
            { finish the parentfpstruct (add padding, ...) }
            { finish the parentfpstruct (add padding, ...) }
            finish_parentfpstruct(current_procinfo.procdef);
            finish_parentfpstruct(current_procinfo.procdef);
          end;
          end;
@@ -2171,7 +2165,7 @@ implementation
 
 
             { translate imag. register to their real counter parts
             { translate imag. register to their real counter parts
               this is necessary for debuginfo and verbose assembler output
               this is necessary for debuginfo and verbose assembler output
-              when SSA will be implented, this will be more complicated because we've to
+              when SSA will be impelented, this will be more complicated because we've to
               maintain location lists }
               maintain location lists }
             procdef.parast.SymList.ForEachCall(@translate_registers,templist);
             procdef.parast.SymList.ForEachCall(@translate_registers,templist);
             procdef.localst.SymList.ForEachCall(@translate_registers,templist);
             procdef.localst.SymList.ForEachCall(@translate_registers,templist);
@@ -2278,7 +2272,19 @@ implementation
             { insert line debuginfo }
             { insert line debuginfo }
             if (cs_debuginfo in current_settings.moduleswitches) or
             if (cs_debuginfo in current_settings.moduleswitches) or
                (cs_use_lineinfo in current_settings.globalswitches) then
                (cs_use_lineinfo in current_settings.globalswitches) then
+             begin
+               { We only do this after the code generated because
+                 otherwise for-loop counters moved to the struct cause
+                 errors. And doing it before optimisation passes have run
+                 causes problems when they manually look up symbols
+                 like result and self (nutils.load_self_node etc). Still
+                 do it nevertheless to to assist debug info generation
+                 (hide original symbols, add absolutevarsyms that redirect
+                  to their new locations in the parentfpstruct) }
+              if assigned(current_procinfo.procdef.parentfpstruct) then
+                redirect_parentfpstruct_local_syms(current_procinfo.procdef);
               current_debuginfo.insertlineinfo(aktproccode);
               current_debuginfo.insertlineinfo(aktproccode);
+             end;
 
 
             finish_eh;
             finish_eh;