فهرست منبع

* execute the tempinitcode whent the tempcreate node gets processed rather
than when the first temprefnode to it gets processed. Solves the issue
the foreachnodestatic processes the tempinitcode when seeing the
tempcreatenode and ignores it when seeing temprefnodes, even though
it may actually be executed/generated for the temprefnode. It's
impossible to easily process it for the "correct" temprefnode
(since there may be multiple temprefnodes for the same tempcreatenode)
o fixes tarray12 for Darwin/i386 and Linux/i386

git-svn-id: trunk@46457 -

Jonas Maebe 5 سال پیش
والد
کامیت
f26735fc77
3فایلهای تغییر یافته به همراه12 افزوده شده و 30 حذف شده
  1. 2 11
      compiler/nbas.pas
  2. 9 13
      compiler/ncgbas.pas
  3. 1 6
      compiler/nutils.pas

+ 2 - 11
compiler/nbas.pas

@@ -140,25 +140,16 @@ interface
            even if the creator didn't mind)
            even if the creator didn't mind)
          }
          }
          ti_addr_taken,
          ti_addr_taken,
-         { temps can get an extra node tree that contains the value to which
-           they should be initialised when they are created. this initialisation
-           has to be performed right before the first reference to the temp.
-           this flag indicates that the ttempcreatenode has been
-           processed by pass_generate_code, but that the first ttemprefnode
-           hasn't yet and hence will have to perform the initialisation
-         }
-         ti_executeinitialisation,
          { in case an expression like "inc(x[func()],1)" is translated into
          { in case an expression like "inc(x[func()],1)" is translated into
            a regular addition, you have to create a temp to hold the address
            a regular addition, you have to create a temp to hold the address
            representing x[func()], since otherwise func() will be called twice
            representing x[func()], since otherwise func() will be called twice
            and that can spell trouble in case it has side effects. on platforms
            and that can spell trouble in case it has side effects. on platforms
-           without pointers, we cannot just take the address though. this flag
-           has to be combined with ti_executeinitialisation above and will,
+           without pointers, we cannot just take the address though. This flag will,
            rather than loading the value at the calculated location and store
            rather than loading the value at the calculated location and store
            it in the temp, keep a copy of the calculated location if possible
            it in the temp, keep a copy of the calculated location if possible
            and required (not possible for regvars, because SSA may change their
            and required (not possible for regvars, because SSA may change their
            register, but not required for them either since calculating their
            register, but not required for them either since calculating their
-           location has no side-effects
+           location has no side-effects)
          }
          }
          ti_reference,
          ti_reference,
          { this temp only allows reading (makes it possible to safely use as
          { this temp only allows reading (makes it possible to safely use as

+ 9 - 13
compiler/ncgbas.pas

@@ -510,20 +510,7 @@ interface
           end;
           end;
         includetempflag(ti_valid);
         includetempflag(ti_valid);
         if assigned(tempinfo^.tempinitcode) then
         if assigned(tempinfo^.tempinitcode) then
-          includetempflag(ti_executeinitialisation);
-      end;
-
-
-{*****************************************************************************
-                             TTEMPREFNODE
-*****************************************************************************}
-
-    procedure tcgtemprefnode.pass_generate_code;
-      begin
-        if ti_executeinitialisation in tempflags then
           begin
           begin
-            { avoid recursion }
-            excludetempflag(ti_executeinitialisation);
             secondpass(tempinfo^.tempinitcode);
             secondpass(tempinfo^.tempinitcode);
             if (ti_reference in tempflags) then
             if (ti_reference in tempflags) then
               begin
               begin
@@ -549,6 +536,15 @@ interface
                 hlcg.g_reference_loc(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.tempinitcode.location,tempinfo^.location);
                 hlcg.g_reference_loc(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.tempinitcode.location,tempinfo^.location);
               end;
               end;
           end;
           end;
+      end;
+
+
+{*****************************************************************************
+                             TTEMPREFNODE
+*****************************************************************************}
+
+    procedure tcgtemprefnode.pass_generate_code;
+      begin
         { check if the temp is valid }
         { check if the temp is valid }
         if not(ti_valid in tempflags) then
         if not(ti_valid in tempflags) then
           internalerror(200108231);
           internalerror(200108231);

+ 1 - 6
compiler/nutils.pas

@@ -1442,12 +1442,7 @@ implementation
                (vo_volatile in tabstractvarsym(tloadnode(n).symtableentry).varoptions)
                (vo_volatile in tabstractvarsym(tloadnode(n).symtableentry).varoptions)
              )
              )
             )
             )
-           ) or
-           { foreachonode does not recurse into the init code for temprefnode as this is done for
-             by the tempcreatenode but the considered tree might not contain the tempcreatenode so play
-             save and recurce into the init code if there is any }
-           ((n.nodetype=temprefn) and (ti_executeinitialisation in ttemprefnode(n).tempflags) and
-            might_have_sideeffects(ttemprefnode(n).tempinfo^.tempinitcode,pmhs_flags(arg)^)) then
+           ) then
            result:=fen_norecurse_true
            result:=fen_norecurse_true
       end;
       end;