Browse Source

* -O4 switch for optimizations which are correct but which might have unexpected effects
like field reordering (possible problems cracker classes) or using ebp as normal register (broken
stack traces from dump_stack)
+ niln is also valid in a cse domain
* parameters passed by reference shall have a complexity >1
* load nodes from outer scopes shall have a complexity >1
* better cse debugging
+ more node types added to cse
* consider parameters passed by reference in cse
* take care of cse in parameters in simple cases

git-svn-id: trunk@22050 -

florian 13 years ago
parent
commit
4d86d25c6c

+ 1 - 0
compiler/arm/cpuinfo.pas

@@ -1087,6 +1087,7 @@ Const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse {,cs_opt_scheduler}];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse {,cs_opt_scheduler}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/avr/cpuinfo.pas

@@ -206,6 +206,7 @@ Const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
    cpu_capabilities : array[tcputype] of set of tcpuflags =
    cpu_capabilities : array[tcputype] of set of tcpuflags =
      ( { cpu_none } [],
      ( { cpu_none } [],

+ 1 - 0
compiler/globtype.pas

@@ -287,6 +287,7 @@ interface
        genericlevel1optimizerswitches = [cs_opt_level1];
        genericlevel1optimizerswitches = [cs_opt_level1];
        genericlevel2optimizerswitches = [cs_opt_level2];
        genericlevel2optimizerswitches = [cs_opt_level2];
        genericlevel3optimizerswitches = [cs_opt_level3];
        genericlevel3optimizerswitches = [cs_opt_level3];
+       genericlevel4optimizerswitches = [cs_opt_reorder_fields];
 
 
        { whole program optimizations whose information generation requires
        { whole program optimizations whose information generation requires
          information from all loaded units
          information from all loaded units

+ 1 - 0
compiler/i386/cpuinfo.pas

@@ -109,6 +109,7 @@ Const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [cs_useebp];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/ia64/cpuinfo.pas

@@ -76,6 +76,7 @@ const
    level2optimizerswitches = level1optimizerswitches + 
    level2optimizerswitches = level1optimizerswitches + 
      [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe,cs_opt_asmcse,cs_opt_nodecse];
      [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe,cs_opt_asmcse,cs_opt_nodecse];
    level3optimizerswitches = level2optimizerswitches + [cs_opt_level3{,cs_opt_loopunroll}];
    level3optimizerswitches = level2optimizerswitches + [cs_opt_level3{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/jvm/cpuinfo.pas

@@ -72,6 +72,7 @@ Const
    level1optimizerswitches = genericlevel1optimizerswitches;
    level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_nodecse];
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/m68k/cpuinfo.pas

@@ -82,6 +82,7 @@ Const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/mips/cpuinfo.pas

@@ -74,6 +74,7 @@ Const
    level1optimizerswitches = [];
    level1optimizerswitches = [];
    level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];
    level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];
    level3optimizerswitches = level2optimizerswitches + [cs_opt_loopunroll];
    level3optimizerswitches = level2optimizerswitches + [cs_opt_loopunroll];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/msg/errore.msg

@@ -3395,6 +3395,7 @@ J*2Cv_Var/out parameter copy-out checking
 **2O1_Level 1 optimizations (quick and debugger friendly)
 **2O1_Level 1 optimizations (quick and debugger friendly)
 **2O2_Level 2 optimizations (-O1 + quick optimizations)
 **2O2_Level 2 optimizations (-O1 + quick optimizations)
 **2O3_Level 3 optimizations (-O2 + slow optimizations)
 **2O3_Level 3 optimizations (-O2 + slow optimizations)
+**2O3_Level 4 optimizations (-O3 + optimizations which might have unexpected side effects)
 **2Oa<x>=<y>_Set alignment
 **2Oa<x>=<y>_Set alignment
 **2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible values
 **2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible values
 **2Op<x>_Set target cpu for optimizing, see fpc -i for possible values
 **2Op<x>_Set target cpu for optimizing, see fpc -i for possible values

+ 1 - 1
compiler/msgidx.inc

@@ -946,7 +946,7 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 66090;
+  MsgTxtSize = 66181;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
     26,92,323,120,87,56,116,26,202,63,
     26,92,323,120,87,56,116,26,202,63,

+ 82 - 81
compiler/msgtxt.inc

@@ -1337,198 +1337,199 @@ const msgtxt : array[0..000275,1..240] of char=(
   '**2O1_Level 1 optimizations (quick and debugger friendly)'#010+
   '**2O1_Level 1 optimizations (quick and debugger friendly)'#010+
   '**2O2_Level 2 optimizations (-O1 + quick optimizations)'#010+
   '**2O2_Level 2 optimizations (-O1 + quick optimizations)'#010+
   '**2O3_Level 3 optimizat','ions (-O2 + slow optimizations)'#010+
   '**2O3_Level 3 optimizat','ions (-O2 + slow optimizations)'#010+
+  '**2O3_Level 4 optimizations (-O3 + optimizations which might have unex'+
+  'pected side effects)'#010+
   '**2Oa<x>=<y>_Set alignment'#010+
   '**2Oa<x>=<y>_Set alignment'#010+
   '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible '+
   '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possible '+
   'values'#010+
   'values'#010+
-  '**2Op<x>_Set target cpu for optimizing, see fpc -i for possible values'+
-  #010+
-  '**2OW<x>_Generate whole-program o','ptimization feedback for optimizati'+
-  'on <x>, see fpc -i for possible values'#010+
+  '**2Op<x>_Set ','target cpu for optimizing, see fpc -i for possible valu'+
+  'es'#010+
+  '**2OW<x>_Generate whole-program optimization feedback for optimization'+
+  ' <x>, see fpc -i for possible values'#010+
   '**2Ow<x>_Perform whole-program optimization <x>, see fpc -i for possib'+
   '**2Ow<x>_Perform whole-program optimization <x>, see fpc -i for possib'+
-  'le values'#010+
+  'le va','lues'#010+
   '**2Os_Optimize for size rather than speed'#010+
   '**2Os_Optimize for size rather than speed'#010+
-  '**1pg_Generate profile code for gprof (defin','es FPC_PROFILE)'#010+
+  '**1pg_Generate profile code for gprof (defines FPC_PROFILE)'#010+
   'F*1P<x>_Target CPU / compiler related options:'#010+
   'F*1P<x>_Target CPU / compiler related options:'#010+
   'F*2PB_Show default compiler binary'#010+
   'F*2PB_Show default compiler binary'#010+
   'F*2PP_Show default target cpu'#010+
   'F*2PP_Show default target cpu'#010+
-  'F*2P<x>_Set target CPU (arm,i386,m68k,mips,mipsel,powerpc,powerpc64,sp'+
-  'arc,x86_64'#010+
-  '**1R<x>_Assembler reading style',':'#010+
+  'F*2P<x>_Set target CP','U (arm,i386,m68k,mips,mipsel,powerpc,powerpc64,'+
+  'sparc,x86_64'#010+
+  '**1R<x>_Assembler reading style:'#010+
   '**2Rdefault_Use default assembler for target'#010+
   '**2Rdefault_Use default assembler for target'#010+
   '3*2Ratt_Read AT&T style assembler'#010+
   '3*2Ratt_Read AT&T style assembler'#010+
   '3*2Rintel_Read Intel style assembler'#010+
   '3*2Rintel_Read Intel style assembler'#010+
-  '6*2RMOT_Read motorola style assembler'#010+
+  '6*2RMOT_Read motorola style ass','embler'#010+
   '**1S<x>_Syntax options:'#010+
   '**1S<x>_Syntax options:'#010+
   '**2S2_Same as -Mobjfpc'#010+
   '**2S2_Same as -Mobjfpc'#010+
-  '**2Sc_Support operators like C (*=,+=',',/= and -=)'#010+
+  '**2Sc_Support operators like C (*=,+=,/= and -=)'#010+
   '**2Sa_Turn on assertions'#010+
   '**2Sa_Turn on assertions'#010+
   '**2Sd_Same as -Mdelphi'#010+
   '**2Sd_Same as -Mdelphi'#010+
   '**2Se<x>_Error options. <x> is a combination of the following:'#010+
   '**2Se<x>_Error options. <x> is a combination of the following:'#010+
-  '**3*_<n> : Compiler halts after the <n> errors (default is 1)'#010+
+  '**3*_<n> : Compiler halts ','after the <n> errors (default is 1)'#010+
   '**3*_w : Compiler also halts after warnings'#010+
   '**3*_w : Compiler also halts after warnings'#010+
-  '**3*_n : Co','mpiler also halts after notes'#010+
+  '**3*_n : Compiler also halts after notes'#010+
   '**3*_h : Compiler also halts after hints'#010+
   '**3*_h : Compiler also halts after hints'#010+
   '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
   '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
-  '**2Sh_Use reference counted strings (ansistring by default) instead of'+
-  ' shortstrings'#010+
-  '**2Si_Turn on inlining of ','procedures/functions declared as "inline"'#010+
+  '**2Sh_Use reference',' counted strings (ansistring by default) instead '+
+  'of shortstrings'#010+
+  '**2Si_Turn on inlining of procedures/functions declared as "inline"'#010+
   '**2Sk_Load fpcylix unit'#010+
   '**2Sk_Load fpcylix unit'#010+
   '**2SI<x>_Set interface style to <x>'#010+
   '**2SI<x>_Set interface style to <x>'#010+
   '**3SIcom_COM compatible interface (default)'#010+
   '**3SIcom_COM compatible interface (default)'#010+
-  '**3SIcorba_CORBA compatible interface'#010+
+  '**3','SIcorba_CORBA compatible interface'#010+
   '**2Sm_Support macros like C (global)'#010+
   '**2Sm_Support macros like C (global)'#010+
-  '**2So_Same as -Mtp'#010,
+  '**2So_Same as -Mtp'#010+
   '**2Ss_Constructor name must be init (destructor must be done)'#010+
   '**2Ss_Constructor name must be init (destructor must be done)'#010+
   '**2Sx_Enable exception keywords (default in Delphi/ObjFPC modes)'#010+
   '**2Sx_Enable exception keywords (default in Delphi/ObjFPC modes)'#010+
-  '**2Sy_@<pointer> returns a typed pointer, same as $T+'#010+
+  '**2Sy_@<pointer> retur','ns a typed pointer, same as $T+'#010+
   '**1s_Do not call assembler and linker'#010+
   '**1s_Do not call assembler and linker'#010+
-  '**2sh_Generate script',' to link on host'#010+
+  '**2sh_Generate script to link on host'#010+
   '**2st_Generate script to link on target'#010+
   '**2st_Generate script to link on target'#010+
   '**2sr_Skip register allocation phase (use with -alr)'#010+
   '**2sr_Skip register allocation phase (use with -alr)'#010+
   '**1T<x>_Target operating system:'#010+
   '**1T<x>_Target operating system:'#010+
-  '3*2Tdarwin_Darwin/Mac OS X'#010+
+  '3*2Tda','rwin_Darwin/Mac OS X'#010+
   '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
   '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
-  '3*2Tfreebsd_FreeBSD'#010,
+  '3*2Tfreebsd_FreeBSD'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+
   '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+
   'rwin)'#010+
   'rwin)'#010+
   '3*2Tlinux_Linux'#010+
   '3*2Tlinux_Linux'#010+
-  '3*2Tnetbsd_NetBSD'#010+
+  '3*2Tnetbs','d_NetBSD'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
-  '3*2Tnetwlibc_Novell Netware Module (libc)',#010+
+  '3*2Tnetwlibc_Novell Netware Module (libc)'#010+
   '3*2Topenbsd_OpenBSD'#010+
   '3*2Topenbsd_OpenBSD'#010+
   '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Tsymbian_Symbian OS'#010+
   '3*2Tsymbian_Symbian OS'#010+
   '3*2Tsolaris_Solaris'#010+
   '3*2Tsolaris_Solaris'#010+
-  '3*2Twatcom_Watcom compatible DOS extender'#010+
+  '3*2Twatcom_Watcom compatible DOS e','xtender'#010+
   '3*2Twdosx_WDOSX DOS extender'#010+
   '3*2Twdosx_WDOSX DOS extender'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*2Twince_Windows CE'#010+
   '3*2Twince_Windows CE'#010+
-  '4*2Tdarw','in_Darwin/Mac OS X'#010+
+  '4*2Tdarwin_Darwin/Mac OS X'#010+
   '4*2Tlinux_Linux'#010+
   '4*2Tlinux_Linux'#010+
   '4*2Twin64_Win64 (64 bit Windows systems)'#010+
   '4*2Twin64_Win64 (64 bit Windows systems)'#010+
   '6*2Tamiga_Commodore Amiga'#010+
   '6*2Tamiga_Commodore Amiga'#010+
   '6*2Tatari_Atari ST/STe/TT'#010+
   '6*2Tatari_Atari ST/STe/TT'#010+
   '6*2Tlinux_Linux'#010+
   '6*2Tlinux_Linux'#010+
-  '6*2Tpalmos_PalmOS'#010+
+  '6*2Tp','almos_PalmOS'#010+
   'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+
   'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+
   'A*2Tlinux_Linux'#010+
   'A*2Tlinux_Linux'#010+
   'A*2Twince_Windows CE'#010+
   'A*2Twince_Windows CE'#010+
-  'P*2Tamiga_','AmigaOS'#010+
+  'P*2Tamiga_AmigaOS'#010+
   'P*2Tdarwin_Darwin/Mac OS X'#010+
   'P*2Tdarwin_Darwin/Mac OS X'#010+
   'P*2Tlinux_Linux'#010+
   'P*2Tlinux_Linux'#010+
   'P*2Tmacos_Mac OS (classic)'#010+
   'P*2Tmacos_Mac OS (classic)'#010+
   'P*2Tmorphos_MorphOS'#010+
   'P*2Tmorphos_MorphOS'#010+
   'S*2Tsolaris_Solaris'#010+
   'S*2Tsolaris_Solaris'#010+
   'S*2Tlinux_Linux'#010+
   'S*2Tlinux_Linux'#010+
-  '**1u<x>_Undefines the symbol <x>'#010+
+  '**1u<x>_Undefin','es the symbol <x>'#010+
   '**1U_Unit options:'#010+
   '**1U_Unit options:'#010+
-  '**2Un_Do not check where the unit name matches the fil','e name'#010+
+  '**2Un_Do not check where the unit name matches the file name'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
   '**2Us_Compile a system unit'#010+
   '**2Us_Compile a system unit'#010+
-  '**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
+  '**1v<x>_Be verbose. <x> is a combination of the',' following letters:'#010+
   '**2*_e : Show errors (default)       0 : Show nothing (except errors)'#010+
   '**2*_e : Show errors (default)       0 : Show nothing (except errors)'#010+
-  '*','*2*_w : Show warnings               u : Show unit info'#010+
+  '**2*_w : Show warnings               u : Show unit info'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
-  '**2*_h : Show hints                  c : Show conditionals'#010+
+  '**2*_h : Show hints            ','      c : Show conditionals'#010+
   '**2*_i : Show general info           d : Show debug info'#010+
   '**2*_i : Show general info           d : Show debug info'#010+
-  '**2*_l',' : Show linenumbers            r : Rhide/GCC compatibility mod'+
-  'e'#010+
+  '**2*_l : Show linenumbers            r : Rhide/GCC compatibility mode'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
-  '**2*_a : Show everything             x : Executable info (Win32 only)'#010+
-  '**2*_b : Write file names messages   p : Wri','te tree.log with parse t'+
-  'ree'#010+
+  '**2*_a : Show everythin','g             x : Executable info (Win32 only'+
+  ')'#010+
+  '**2*_b : Write file names messages   p : Write tree.log with parse tre'+
+  'e'#010+
   '**2*_    with full path              v : Write fpcdebug.txt with'#010+
   '**2*_    with full path              v : Write fpcdebug.txt with'#010+
-  '**2*_                                    lots of debugging info'#010+
+  '**2*_                                    lots of debuggi','ng info'#010+
   '**2*_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
   '**2*_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
-  'F*1V<x>_Append '#039'-<x>'#039' to t','he used compiler binary name (e.g.'+
-  ' for version)'#010+
+  'F*1V<x>_Append '#039'-<x>'#039' to the used compiler binary name (e.g. f'+
+  'or version)'#010+
   '**1W<x>_Target-specific options (targets)'#010+
   '**1W<x>_Target-specific options (targets)'#010+
   '3*2WA_Specify native type application (Windows)'#010+
   '3*2WA_Specify native type application (Windows)'#010+
-  '4*2WA_Specify native type application (Windows)'#010+
+  '4*2WA_Speci','fy native type application (Windows)'#010+
   'A*2WA_Specify native type application (Windows)'#010+
   'A*2WA_Specify native type application (Windows)'#010+
-  '3*2Wb_','Create a bundle instead of a library (Darwin)'#010+
+  '3*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'P*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'P*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
+  'p*2Wb_Create a bundle instead of a library (Darwin)',#010+
   'A*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'A*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  '4*2Wb_Create a bundle instead of a lib','rary (Darwin)'#010+
+  '4*2Wb_Create a bundle instead of a library (Darwin)'#010+
   '3*2WB_Create a relocatable image (Windows, Symbian)'#010+
   '3*2WB_Create a relocatable image (Windows, Symbian)'#010+
   '3*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+
   '3*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+
-  '4*2WB_Create a relocatable image (Windows)'#010+
+  '4*2WB_Create a relocatable imag','e (Windows)'#010+
   '4*2WBxxxx_Set image base to xxxx (Windows)'#010+
   '4*2WBxxxx_Set image base to xxxx (Windows)'#010+
-  'A*2WB_Create a relocatable image (Wi','ndows, Symbian)'#010+
+  'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
   'A*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+
   'A*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+
   '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
   '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
-  '4*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
+  '4*2WC_Specify console',' type application (EMX, OS/2, Windows)'#010+
   'A*2WC_Specify console type application (Windows)'#010+
   'A*2WC_Specify console type application (Windows)'#010+
-  'P*2','WC_Specify console type application (Classic Mac OS)'#010+
+  'P*2WC_Specify console type application (Classic Mac OS)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
-  '4*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
+  '4*2WD_Use DEFFILE to export functi','ons of DLL or EXE (Windows)'#010+
   'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
-  '3','*2We_Use external resources (Darwin)'#010+
+  '3*2We_Use external resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
-  'P*2We_Use external resources (Darwin)'#010+
+  'P*2We_Use external resources (Darwin',')'#010+
   'p*2We_Use external resources (Darwin)'#010+
   'p*2We_Use external resources (Darwin)'#010+
-  '3*2WF_Specify full-screen type application (EMX, OS','/2)'#010+
+  '3*2WF_Specify full-screen type application (EMX, OS/2)'#010+
   '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
   '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
   '4*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
   '4*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
-  'A*2WG_Specify graphic type application (Windows)'#010+
+  'A*2WG_Specify graphic typ','e application (Windows)'#010+
   'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
   'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
-  '3*2Wi_Use i','nternal resources (Darwin)'#010+
+  '3*2Wi_Use internal resources (Darwin)'#010+
   '4*2Wi_Use internal resources (Darwin)'#010+
   '4*2Wi_Use internal resources (Darwin)'#010+
   'A*2Wi_Use internal resources (Darwin)'#010+
   'A*2Wi_Use internal resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
-  'p*2Wi_Use internal resources (Darwin)'#010+
+  'p*2Wi_Us','e internal resources (Darwin)'#010+
   '3*2WI_Turn on/off the usage of import sections (Windows)'#010+
   '3*2WI_Turn on/off the usage of import sections (Windows)'#010+
-  '4*2W','I_Turn on/off the usage of import sections (Windows)'#010+
+  '4*2WI_Turn on/off the usage of import sections (Windows)'#010+
   'A*2WI_Turn on/off the usage of import sections (Windows)'#010+
   'A*2WI_Turn on/off the usage of import sections (Windows)'#010+
-  '3*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
-  'n)'#010+
-  '4*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.','1, ... (Dar'+
+  '3*2WM<x>_Minimum Mac OS X deployment ve','rsion: 10.4, 10.5.1, ... (Dar'+
   'win)'#010+
   'win)'#010+
-  'p*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
+  '4*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
   'n)'#010+
-  'P*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
+  'p*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
   'n)'#010+
+  'P*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ','... (Dar'+
+  'win)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  '4*2WN_Do',' not generate relocation code, needed for debugging (Windows'+
-  ')'#010+
+  '4*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  'A*2Wpxxxx_Specify the controller type, see fpc -i for possible values'#010+
-  'V*2Wpxxxx_Specify the controller type,',' see fpc -i for possible value'+
+  'A*2Wpxxxx_Specify',' the controller type, see fpc -i for possible value'+
   's'#010+
   's'#010+
+  'V*2Wpxxxx_Specify the controller type, see fpc -i for possible values'#010+
   '3*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (iphonesim)'#010+
   '3*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (iphonesim)'#010+
-  'A*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (Darwin)'#010+
+  'A*2WP<x>_Minimum iOS deployment version: 3.0, 5.','0.1, ... (Darwin)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
-  '4*2WR_Generate relocation code (','Windows)'#010+
+  '4*2WR_Generate relocation code (Windows)'#010+
   'A*2WR_Generate relocation code (Windows)'#010+
   'A*2WR_Generate relocation code (Windows)'#010+
   'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
   'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
   '**2WX_Enable executable stack (Linux)'#010+
   '**2WX_Enable executable stack (Linux)'#010+
-  '**1X_Executable options:'#010+
-  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin',
+  '**1X','_Executable options:'#010+
+  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
   'ux)'#010+
   'ux)'#010+
   '**2Xd_Do not search default library path (sometimes required for cross'+
   '**2Xd_Do not search default library path (sometimes required for cross'+
   '-compiling when not using -XR)'#010+
   '-compiling when not using -XR)'#010+
   '**2Xe_Use external linker'#010+
   '**2Xe_Use external linker'#010+
-  '**2Xg_Create debuginfo in a separate file and add a debuglink section '+
-  'to executable'#010+
-  '**2XD_Try to link units d','ynamically      (defines FPC_LINK_DYNAMIC)'#010+
+  '**2Xg_Create debug','info in a separate file and add a debuglink sectio'+
+  'n to executable'#010+
+  '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
   '**2Xi_Use internal linker'#010+
   '**2Xi_Use internal linker'#010+
   '**2Xm_Generate link map'#010+
   '**2Xm_Generate link map'#010+
-  '**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
-  's '#039'main'#039')'#010+
+  '**2XM<x>_Set the name of the '#039'main'#039' program routine (def','ault'+
+  ' is '#039'main'#039')'#010+
   'F*2Xp<x>_First search for the compiler binary in the directory <x>'#010+
   'F*2Xp<x>_First search for the compiler binary in the directory <x>'#010+
-  '**2XP<x>','_Prepend the binutils names with the prefix <x>'#010+
+  '**2XP<x>_Prepend the binutils names with the prefix <x>'#010+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
-  'ile, see the ld manual for more information) (BeOS, Linux)'#010+
-  '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, Free','B'+
-  'SD, Linux, Mac OS, Solaris)'#010+
+  'ile, see the ld manual for more inf','ormation) (BeOS, Linux)'#010+
+  '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
+  ', Linux, Mac OS, Solaris)'#010+
   '**2Xs_Strip all symbols from executable'#010+
   '**2Xs_Strip all symbols from executable'#010+
   '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
   '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
-  '**2Xt_Link with static libraries (-static is passed to linker)'#010+
-  '**2XX_Try to smartlink units          ','   (defines FPC_LINK_SMART)'#010+
+  '**2Xt_Link',' with static libraries (-static is passed to linker)'#010+
+  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
   '**1*_'#010+
   '**1*_'#010+
   '**1?_Show this help'#010+
   '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'
   '**1h_Shows this help without waiting'

+ 6 - 3
compiler/ncal.pas

@@ -3747,6 +3747,7 @@ implementation
                     { parameter expression, so in that case assign to a temp   }
                     { parameter expression, so in that case assign to a temp   }
                     not(para.left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CONSTANT]) or
                     not(para.left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CONSTANT]) or
                     ((paracomplexity > 1) and
                     ((paracomplexity > 1) and
+                      not(nf_is_funcret in para.left.flags) and
                      (not valid_for_addr(para.left,false) or
                      (not valid_for_addr(para.left,false) or
                       (para.left.nodetype = calln) or
                       (para.left.nodetype = calln) or
                       is_constnode(para.left))) or
                       is_constnode(para.left))) or
@@ -3841,9 +3842,11 @@ implementation
                 { occurrences of the parameter with dereferencings of this    }
                 { occurrences of the parameter with dereferencings of this    }
                 { temp                                    }
                 { temp                                    }
                 else
                 else
-                  { don't create a temp. for the often seen case that p^ is passed to a var parameter }
-                  if (paracomplexity>2) or
-                    ((paracomplexity>1) and not((para.left.nodetype=derefn) and (para.parasym.varspez = vs_var))) then
+                  { don't create a temp. for function results }
+                  if not(nf_is_funcret in para.left.flags) and
+                     ((paracomplexity>2) or
+                     { don't create a temp. for the often seen case that p^ is passed to a var parameter }
+                    ((paracomplexity>1) and not((para.left.nodetype=derefn) and (para.parasym.varspez = vs_var)))) then
                   begin
                   begin
                     wrapcomplexinlinepara(para);
                     wrapcomplexinlinepara(para);
                   end;
                   end;

+ 3 - 1
compiler/nutils.pas

@@ -564,6 +564,8 @@ implementation
                     inc(result,5)
                     inc(result,5)
                   else
                   else
                     inc(result);
                     inc(result);
+                  if (tloadnode(p).symtableentry.typ=paravarsym) and tloadnode(p).is_addr_param_load then
+                    inc(result);
                   if (result >= NODE_COMPLEXITY_INF) then
                   if (result >= NODE_COMPLEXITY_INF) then
                     result := NODE_COMPLEXITY_INF;
                     result := NODE_COMPLEXITY_INF;
                   exit;
                   exit;
@@ -593,7 +595,7 @@ implementation
               typeconvn:
               typeconvn:
                 begin
                 begin
                   { may be more complex in some cases }
                   { may be more complex in some cases }
-                  if not(ttypeconvnode(p).convtype in [tc_equal,tc_int_2_int,tc_bool_2_bool,tc_real_2_real,tc_cord_2_pointer]) then
+                  if not(ttypeconvnode(p).retains_value_location) then
                     inc(result);
                     inc(result);
                   if (result = NODE_COMPLEXITY_INF) then
                   if (result = NODE_COMPLEXITY_INF) then
                     exit;
                     exit;

+ 20 - 5
compiler/optcse.pas

@@ -64,7 +64,8 @@ unit optcse;
     const
     const
       cseinvariant : set of tnodetype = [addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
       cseinvariant : set of tnodetype = [addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
         derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn,
         derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn,
-        inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn,
+        inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn,niln,
+        setelementn,arrayconstructorn,arrayconstructorrangen,
         isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan},assignn];
         isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan},assignn];
 
 
     function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
     function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
@@ -73,6 +74,7 @@ unit optcse;
           ((n.nodetype=inlinen) and
           ((n.nodetype=inlinen) and
            (tinlinenode(n).inlinenumber in [in_assigned_x])
            (tinlinenode(n).inlinenumber in [in_assigned_x])
           ) or
           ) or
+          ((n.nodetype=callparan) and not(assigned(tcallparanode(n).right))) or
           ((n.nodetype=loadn) and
           ((n.nodetype=loadn) and
             not((tloadnode(n).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) and
             not((tloadnode(n).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) and
                 (vo_volatile in tabstractvarsym(tloadnode(n).symtableentry).varoptions))
                 (vo_volatile in tabstractvarsym(tloadnode(n).symtableentry).varoptions))
@@ -133,8 +135,9 @@ unit optcse;
             (not(n.resultdef.typ in [arraydef,recorddef])) and
             (not(n.resultdef.typ in [arraydef,recorddef])) and
             { same for voiddef }
             { same for voiddef }
             not(is_void(n.resultdef)) and
             not(is_void(n.resultdef)) and
-            { adding tempref nodes is worthless but their complexity is probably <= 1 anyways }
-            not(n.nodetype in [temprefn]) and
+            { adding tempref and callpara nodes itself is worthless but
+              their complexity is probably <= 1 anyways }
+            not(n.nodetype in [temprefn,callparan]) and
 
 
             { node worth to add?
             { node worth to add?
 
 
@@ -151,7 +154,7 @@ unit optcse;
             }
             }
             (not(n.nodetype=loadn) or
             (not(n.nodetype=loadn) or
              not(tloadnode(n).symtableentry.typ in [paravarsym,localvarsym]) or
              not(tloadnode(n).symtableentry.typ in [paravarsym,localvarsym]) or
-             (tloadnode(n).symtable.symtablelevel<>current_procinfo.procdef.parast.symtablelevel)
+             (node_complexity(n)>1)
             ) and
             ) and
 
 
             {
             {
@@ -367,9 +370,13 @@ unit optcse;
                         addrstored:=(def.typ in [arraydef,recorddef]) or is_object(def);
                         addrstored:=(def.typ in [arraydef,recorddef]) or is_object(def);
 
 
 {$if defined(csedebug) or defined(csestats)}
 {$if defined(csedebug) or defined(csestats)}
+                        writeln;
+                        writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+                        writeln('Complexity: ',node_complexity(tnode(lists.nodelist[i])),'  Node ',i,' equals Node ',ptrint(lists.equalto[i]));
                         printnode(output,tnode(lists.nodelist[i]));
                         printnode(output,tnode(lists.nodelist[i]));
-                        writeln(i,'    equals   ',ptrint(lists.equalto[i]));
                         printnode(output,tnode(lists.nodelist[ptrint(lists.equalto[i])]));
                         printnode(output,tnode(lists.nodelist[ptrint(lists.equalto[i])]));
+                        writeln('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+                        writeln;
 {$endif defined(csedebug) or defined(csestats)}
 {$endif defined(csedebug) or defined(csestats)}
                         templist[i]:=templist[ptrint(lists.equalto[i])];
                         templist[i]:=templist[ptrint(lists.equalto[i])];
                         if addrstored then
                         if addrstored then
@@ -427,6 +434,14 @@ unit optcse;
 
 
     function do_optcse(var rootnode : tnode) : tnode;
     function do_optcse(var rootnode : tnode) : tnode;
       begin
       begin
+{$ifdef csedebug}
+         writeln('====================================================================================');
+         writeln('CSE optimization pass started');
+         writeln('====================================================================================');
+         printnode(rootnode);
+         writeln('====================================================================================');
+         writeln;
+{$endif csedebug}
         foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,nil);
         foreachnodestatic(pm_postprocess,rootnode,@searchcsedomain,nil);
         result:=nil;
         result:=nil;
       end;
       end;

+ 2 - 0
compiler/options.pas

@@ -1351,6 +1351,8 @@ begin
                       init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
                       init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
                     '3' :
                     '3' :
                       init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
                       init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
+                    '4' :
+                      init_settings.optimizerswitches:=init_settings.optimizerswitches+level4optimizerswitches;
                     'a' :
                     'a' :
                       begin
                       begin
                         if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then
                         if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then

+ 1 - 0
compiler/powerpc/cpuinfo.pas

@@ -83,6 +83,7 @@ Const
    level1optimizerswitches = genericlevel1optimizerswitches;
    level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_regvar,cs_opt_nodecse,cs_opt_tailrecursion];
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_regvar,cs_opt_nodecse,cs_opt_tailrecursion];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation
 
 

+ 1 - 0
compiler/powerpc64/cpuinfo.pas

@@ -76,6 +76,7 @@ const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse,cs_opt_tailrecursion];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse,cs_opt_tailrecursion];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 implementation
 implementation
 
 

+ 1 - 0
compiler/sparc/cpuinfo.pas

@@ -84,6 +84,7 @@ const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
      [cs_opt_regvar,cs_opt_tailrecursion,cs_opt_nodecse];
      [cs_opt_regvar,cs_opt_tailrecursion,cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 implementation
 implementation
 
 

+ 1 - 0
compiler/x86_64/cpuinfo.pas

@@ -97,6 +97,7 @@ Const
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + 
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
+   level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
 
 Implementation
 Implementation