From 63f6afffd51bb66dd0b7bf4672733d5ad6355c1c Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 14 Feb 2013 21:40:04 +0000 Subject: [PATCH] + make empty proc. removal switchable by removeemptyprocs git-svn-id: trunk@23621 - --- compiler/globtype.pas | 10 ++++++---- compiler/ncal.pas | 2 +- compiler/nobj.pas | 2 +- compiler/psub.pas | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index befb16f6b2..cc359f64e4 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -257,7 +257,9 @@ interface explicit side-effects, only implicit side-effects (like the ones mentioned before) can disappear. } - cs_opt_dead_values + cs_opt_dead_values, + { compiler checks for empty procedures/methods and removes calls to them if possible } + cs_opt_remove_emtpy_proc ); toptimizerswitches = set of toptimizerswitch; @@ -284,12 +286,12 @@ interface end; const - OptimizerSwitchStr : array[toptimizerswitch] of string[11] = ('', + OptimizerSwitchStr : array[toptimizerswitch] of string[16] = ('', 'LEVEL1','LEVEL2','LEVEL3', 'REGVAR','UNCERTAIN','SIZE','STACKFRAME', 'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE', 'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP', - 'ORDERFIELDS','FASTMATH','DEADVALUES' + 'ORDERFIELDS','FASTMATH','DEADVALUES','REMOVEEMPTYPROCS' ); WPOptimizerSwitchStr : array [twpoptimizerswitch] of string[14] = ( 'DEVIRTCALLS','OPTVMTS','SYMBOLLIVENESS' @@ -310,7 +312,7 @@ interface { switches being applied to all CPUs at the given level } genericlevel1optimizerswitches = [cs_opt_level1]; - genericlevel2optimizerswitches = [cs_opt_level2]; + genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc]; genericlevel3optimizerswitches = [cs_opt_level3]; genericlevel4optimizerswitches = [cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath]; diff --git a/compiler/ncal.pas b/compiler/ncal.pas index 12525e9776..f18c9b7a19 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -3461,7 +3461,7 @@ implementation Message(parser_e_no_category_as_types); { can we get rid of the call? } - if (cs_opt_level2 in current_settings.optimizerswitches) and + if (cs_opt_remove_emtpy_proc in current_settings.optimizerswitches) and not(cnf_return_value_used in callnodeflags) and (procdefinition.typ=procdef) and tprocdef(procdefinition).isempty and diff --git a/compiler/nobj.pas b/compiler/nobj.pas index 5d0ab815b2..e7d7ec6d8d 100644 --- a/compiler/nobj.pas +++ b/compiler/nobj.pas @@ -1573,7 +1573,7 @@ implementation internalerror(200611083); if (po_abstractmethod in vmtpd.procoptions) then procname:='FPC_ABSTRACTERROR' - else if (cs_opt_level2 in current_settings.optimizerswitches) and RedirectToEmpty(vmtpd) then + else if (cs_opt_remove_emtpy_proc in current_settings.optimizerswitches) and RedirectToEmpty(vmtpd) then procname:='FPC_EMPTYMETHOD' else if not wpoinfomanager.optimized_name_for_vmt(_class,vmtpd,procname) then procname:=vmtpd.mangledname; diff --git a/compiler/psub.pas b/compiler/psub.pas index 001c7a35b8..4e94d2d145 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -1268,7 +1268,8 @@ implementation if cs_opt_nodecse in current_settings.optimizerswitches then do_optcse(code); - if (procdef.proctypeoption in [potype_operator,potype_procedure,potype_function]) and + if (cs_opt_remove_emtpy_proc in current_settings.optimizerswitches) and + (procdef.proctypeoption in [potype_operator,potype_procedure,potype_function]) and (code.nodetype=blockn) and (tblocknode(code).statements=nil) then procdef.isempty:=true;