diff --git a/compiler/arm/narminl.pas b/compiler/arm/narminl.pas index ca01572a8c..a251556fed 100644 --- a/compiler/arm/narminl.pas +++ b/compiler/arm/narminl.pas @@ -64,7 +64,7 @@ implementation cpuinfo, defutil,symdef,aasmdata,aasmcpu, cgbase,cgutils,pass_1,pass_2, cpubase,ncgutil,cgobj,cgcpu, hlcgobj, - ncal; + nutils,ncal; {***************************************************************************** tarminlinenode @@ -384,12 +384,13 @@ implementation begin if not(GenerateThumbCode) and (CPUARM_HAS_EDSP in cpu_capabilities[current_settings.cputype]) then begin - { do not call Checkpointer for left node } - checkpointer_used:=(cs_checkpointer in current_settings.localswitches); - exclude(current_settings.localswitches,cs_checkpointer); - secondpass(left); - if checkpointer_used then - include(current_settings.localswitches,cs_checkpointer); + { do not call Checkpointer for left node } + checkpointer_used:=(cs_checkpointer in current_settings.localswitches); + if checkpointer_used then + node_change_local_switch(left,cs_checkpointer,false); + secondpass(left); + if checkpointer_used then + node_change_local_switch(left,cs_checkpointer,false); case left.location.loc of LOC_CREFERENCE, LOC_REFERENCE: diff --git a/compiler/nutils.pas b/compiler/nutils.pas index df2c766824..01223f0beb 100644 --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -148,6 +148,9 @@ interface { excludes the flags passed in nf from the node tree passed } procedure node_reset_flags(p : tnode;nf : tnodeflags); + { include or exclude cs from p.localswitches } + procedure node_change_local_switch(p : tnode;cs : tlocalswitch;enable : boolean); + implementation uses @@ -1404,4 +1407,30 @@ implementation foreachnodestatic(p,@do_node_reset_flags,@nf); end; + type + tlocalswitchchange = record + cs : tlocalswitch; + enable : boolean; + end; + plocalswitchchange = ^tlocalswitchchange; + + + function do_change_local_settings(var p : tnode;plsc : pointer) : foreachnoderesult; + begin + if plocalswitchchange(plsc)^.enable then + include(p.localswitches, plocalswitchchange(plsc)^.cs) + else + exclude(p.localswitches, plocalswitchchange(plsc)^.cs); + result:=fen_true; + end; + + procedure node_change_local_switch(p : tnode;cs : tlocalswitch;enable : boolean); + var + lsc : tlocalswitchchange; + begin + lsc.cs:=cs; + lsc.enable:=enable; + foreachnodestatic(p,@do_change_local_settings,@lsc); + end; + end. diff --git a/compiler/ppcgen/ngppcinl.pas b/compiler/ppcgen/ngppcinl.pas index eeee867f27..828294c53f 100644 --- a/compiler/ppcgen/ngppcinl.pas +++ b/compiler/ppcgen/ngppcinl.pas @@ -59,7 +59,7 @@ implementation symconst,symdef, defutil, cgbase,pass_2, - cpuinfo,ncgutil, + cpuinfo,ncgutil,nutils, hlcgobj,cgutils,cgobj,rgobj,tgobj; @@ -209,10 +209,11 @@ implementation begin { do not call Checkpointer for left node } checkpointer_used:=(cs_checkpointer in current_settings.localswitches); - exclude(current_settings.localswitches,cs_checkpointer); + if checkpointer_used then + node_change_local_switch(left,cs_checkpointer,false); secondpass(left); if checkpointer_used then - include(current_settings.localswitches,cs_checkpointer); + node_change_local_switch(left,cs_checkpointer,false); case left.location.loc of LOC_CREFERENCE, LOC_REFERENCE: diff --git a/compiler/x86/nx86inl.pas b/compiler/x86/nx86inl.pas index 7ebbc8e28c..033b7e3c48 100644 --- a/compiler/x86/nx86inl.pas +++ b/compiler/x86/nx86inl.pas @@ -84,7 +84,7 @@ implementation aasmbase,aasmtai,aasmdata,aasmcpu, symtype,symdef,symcpu, cgbase,pass_2, - cpuinfo,cpubase,paramgr, + cpuinfo,cpubase,paramgr,nutils, nbas,ncon,ncal,ncnv,nld,ncgutil, tgobj, cga,cgutils,cgx86,cgobj,hlcgobj; @@ -599,10 +599,11 @@ implementation begin { do not call Checkpointer for left node } checkpointer_used:=(cs_checkpointer in current_settings.localswitches); - exclude(current_settings.localswitches,cs_checkpointer); + if checkpointer_used then + node_change_local_switch(left,cs_checkpointer,false); secondpass(left); if checkpointer_used then - include(current_settings.localswitches,cs_checkpointer); + node_change_local_switch(left,cs_checkpointer,false); case left.location.loc of LOC_CREFERENCE, LOC_REFERENCE: