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

* use current node's localswitches field for checking whether range and overflow
checking is on, when handling the inc/dec inline nodes, instead of using
current_settings.localswitches
* when creating inline nodes in the optloadmodifystore optimization pass, copy
localswitches from the node, that is being replaced, because otherwise,
localswitches is copied from current_settings.localswitches at the time the
new node is created, and that can already be in a different state, since
optloadmodifystore is performed in a separate pass, after the current
procedure has already been parsed and in this moment, it reflects the state
of localswitches after the end of the procedure.
* these two fixes fix a bug, where an internalerror 2017032701 can happen, when
compiling with -O3 code that turns on and off range/overflow checking in the
middle of a procedure.

git-svn-id: trunk@36195 -

nickysn 8 жил өмнө
parent
commit
a7ca75a4b6

+ 2 - 2
compiler/ninl.pas

@@ -3193,7 +3193,7 @@ implementation
                             begin
                               set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
                               { these nodes shouldn't be created, when range checking is on }
-                              if [cs_check_range,cs_check_overflow]*current_settings.localswitches<>[] then
+                              if [cs_check_range,cs_check_overflow]*localswitches<>[] then
                                 internalerror(2017032701);
                               if inlinenumber in [in_sar_assign_x_y,in_shl_assign_x_y,in_shr_assign_x_y,in_rol_assign_x_y,in_ror_assign_x_y] then
                                 inserttypeconv(tcallparanode(left).left,sinttype)
@@ -4251,7 +4251,7 @@ implementation
 
          { range/overflow checking doesn't work properly }
          { with the inc/dec code that's generated (JM)   }
-         if ((current_settings.localswitches * [cs_check_overflow,cs_check_range] <> []) and
+         if ((localswitches * [cs_check_overflow,cs_check_range] <> []) and
            { No overflow check for pointer operations, because inc(pointer,-1) will always
              trigger an overflow. For uint32 it works because then the operation is done
              in 64bit. Range checking is not applicable to pointers either }

+ 7 - 0
compiler/optloadmodifystore.pas

@@ -62,6 +62,7 @@ unit optloadmodifystore;
                 result:=cinlinenode.createintern(
                   newinlinenodetype,false,ccallparanode.create(
                   tinlinenode(right).left,nil));
+                result.localswitches:=localswitches;
                 tinlinenode(right).left:=nil;
                 exit;
               end;
@@ -101,6 +102,7 @@ unit optloadmodifystore;
                   result:=cinlinenode.createintern(
                     newinlinenodetype,false,ccallparanode.create(
                     taddnode(right).right,ccallparanode.create(taddnode(right).left,nil)));
+                result.localswitches:=localswitches;
                 taddnode(right).left:=nil;
                 taddnode(right).right:=nil;
                 exit;
@@ -155,6 +157,7 @@ unit optloadmodifystore;
                   result:=cinlinenode.createintern(
                     newinlinenodetype,false,ccallparanode.create(
                     taddnode(ttypeconvnode(right).left).right,ccallparanode.create(ttypeconvnode(taddnode(ttypeconvnode(right).left).left).left,nil)));
+                result.localswitches:=localswitches;
                 ttypeconvnode(taddnode(ttypeconvnode(right).left).left).left:=nil;
                 taddnode(ttypeconvnode(right).left).right:=nil;
                 exit;
@@ -192,6 +195,7 @@ unit optloadmodifystore;
                   result:=cinlinenode.createintern(
                     newinlinenodetype,false,ccallparanode.create(
                     taddnode(right).left,ccallparanode.create(taddnode(right).right,nil)));
+                result.localswitches:=localswitches;
                 taddnode(right).right:=nil;
                 taddnode(right).left:=nil;
                 exit;
@@ -243,6 +247,7 @@ unit optloadmodifystore;
                   result:=cinlinenode.createintern(
                     newinlinenodetype,false,ccallparanode.create(
                     taddnode(ttypeconvnode(right).left).left,ccallparanode.create(ttypeconvnode(taddnode(ttypeconvnode(right).left).right).left,nil)));
+                result.localswitches:=localswitches;
                 ttypeconvnode(taddnode(ttypeconvnode(right).left).right).left:=nil;
                 taddnode(ttypeconvnode(right).left).left:=nil;
                 exit;
@@ -265,6 +270,7 @@ unit optloadmodifystore;
                   newinlinenodetype:=in_neg_assign_x;
                 result:=cinlinenode.createintern(
                   newinlinenodetype,false,tunarynode(right).left);
+                result.localswitches:=localswitches;
                 tunarynode(right).left:=nil;
                 exit;
               end;
@@ -297,6 +303,7 @@ unit optloadmodifystore;
                   newinlinenodetype:=in_neg_assign_x;
                 result:=cinlinenode.createintern(
                   newinlinenodetype,false,ttypeconvnode(tunarynode(ttypeconvnode(right).left).left).left);
+                result.localswitches:=localswitches;
                 ttypeconvnode(tunarynode(ttypeconvnode(right).left).left).left:=nil;
                 exit;
               end;