00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <sys/types.h>
00057 #if ! defined(BUILD_OS_DARWIN)
00058 #include <elf.h>
00059 #endif
00060 #include <cmplrs/rcodes.h>
00061 #include <dirent.h>
00062 #ifndef __MINGW32__
00063 #include <libgen.h>
00064 #endif
00065
00066 #include "defs.h"
00067 #if !defined(SHARED_BUILD)
00068 #define load_so(a,b,c)
00069 #else
00070 #include "dso.h"
00071 #endif
00072 #include "errors.h"
00073 #include "err_host.tab"
00074 #include "erglob.h"
00075 #include "erauxdesc.h"
00076 #include "mempool.h"
00077 #include "phase.h"
00078 #include "be_util.h"
00079 #include "wn.h"
00080 #include "driver_util.h"
00081 #include "timing.h"
00082 #include "glob.h"
00083 #include "stab.h"
00084 #include "pu_info.h"
00085 #include "ir_bread.h"
00086 #include "ir_bwrite.h"
00087 #include "config.h"
00088 #include "config_opt.h"
00089 #include "config_list.h"
00090 #include "config_lno.h"
00091 #include "config_cache.h"
00092 #include "file_util.h"
00093 #include "xstats.h"
00094 #include "data_layout.h"
00095 #include "opt_alias_interface.h"
00096 #include "wn_lower.h"
00097 #include "cgdriver.h"
00098 #include "optimizer.h"
00099 #include "ori.h"
00100 #include "wodriver.h"
00101 #ifndef BUILD_SKIP_LNO
00102 #include "lnodriver.h"
00103 #include "ipl_driver.h"
00104 #endif
00105 #ifndef BUILD_SKIP_WHIRL2C
00106 #include "w2c_driver.h"
00107 #endif
00108 #ifndef BUILD_SKIP_WHIRL2F
00109 #include "w2f_driver.h"
00110 #endif
00111 #ifndef BUILD_SKIP_PURPLE
00112 #include "prp_driver.h"
00113 #endif
00114 #ifndef BUILD_SKIP_PROMPF
00115 #include "anl_driver.h"
00116 #endif
00117 #include "region_util.h"
00118 #include "region_main.h"
00119 #include "cg/cg.h"
00120 #include "tracing.h"
00121 #include "ir_reader.h"
00122 #include "dwarf_DST.h"
00123 #include "fb_whirl.h"
00124 #include "eh_region.h"
00125 #include "vho_lower.h"
00126 #include "iter.h"
00127 #include "dra_export.h"
00128 #include "ti_init.h"
00129 #include "opt_alias_interface.h"
00130 #include "omp_lower.h"
00131 #include "cxx_memory.h"
00132 #include "options_stack.h"
00133 #include "be_symtab.h"
00134 #include "prompf.h"
00135 #include "wb_omp.h"
00136 #include "wb_lwr.h"
00137 #include "wb_anl.h"
00138 #include "wn_instrument.h"
00139 #include "mem_ctr.h"
00140 #ifndef ipl_reorder_INCLUDED // for Preprocess_struct_access()
00141 #include "ipl_reorder.h"
00142 #endif
00143 #include "config_ipa.h"
00144 #ifdef KEY
00145 #include "config_wopt.h"
00146 #include "config_vho.h"
00147 #include "output_func_start_profiler.h"
00148 #include "goto_conv.h"
00149 #endif
00150 #include "be_memop_annot.h"
00151 #if defined(TARG_SL) || defined(TARG_MIPS)
00152 #include <dlfcn.h>
00153 #include "topcode.h"
00154 #include "ti_si.h"
00155 #include "isr.h"
00156 #endif
00157
00158 extern ERROR_DESC EDESC_BE[], EDESC_CG[];
00159
00160 #ifdef KEY
00161 #include "demangle.h"
00162 extern "C" char *cplus_demangle (const char *, int);
00163 extern void Recompute_addr_saved_stmt (WN *);
00164 extern void Set_addr_saved_stmt (WN *, BOOL);
00165 extern void CYG_Instrument_Driver(WN *);
00166 #endif
00167
00168 extern void Initialize_Targ_Info(void);
00169
00170
00171 #if defined(SHARED_BUILD)
00172 #if defined(__linux__) || defined(BUILD_OS_DARWIN) || defined(__CYGWIN__) || defined(__MINGW32__)
00173 #if !defined(BUILD_FAST_BIN)
00174 extern void (*CG_Process_Command_Line_p) (INT, char **, INT, char **);
00175 #define CG_Process_Command_Line (*CG_Process_Command_Line_p)
00176
00177 extern void (*CG_Init_p) ();
00178 #define CG_Init (*CG_Init_p)
00179
00180 extern void (*CG_Fini_p) ();
00181 #define CG_Fini (*CG_Fini_p)
00182
00183 extern void (*CG_PU_Initialize_p) (WN*);
00184 #define CG_PU_Initialize (*CG_PU_Initialize_p)
00185
00186 extern void (*CG_PU_Finalize_p) ();
00187 #define CG_PU_Finalize (*CG_PU_Finalize_p)
00188
00189 extern WN* (*CG_Generate_Code_p) (WN*, ALIAS_MANAGER*, DST_IDX, BOOL);
00190 #define CG_Generate_Code (*CG_Generate_Code_p)
00191
00192 extern void (*EH_Generate_Range_List_p) (WN *);
00193 #define EH_Generate_Range_List (*EH_Generate_Range_List_p)
00194
00195
00196 extern void (*EH_Dump_INITOs_p) (WN *, FILE *);
00197 #define EH_Dump_INITOs (*EH_Dump_INITOs_p)
00198 #else
00199 extern void CG_Process_Command_Line (INT, char **, INT, char **);
00200 extern void CG_Init ();
00201 extern void CG_Fini ();
00202 extern void CG_PU_Initialize (WN*);
00203 extern void CG_PU_Finalize ();
00204 extern WN* CG_Generate_Code (WN*, ALIAS_MANAGER*, DST_IDX, BOOL);
00205 extern void EH_Generate_Range_List (WN *);
00206 #endif //BUILD_FAST_BIN
00207
00208 #else
00209
00210 #pragma weak CG_Process_Command_Line
00211 #pragma weak CG_Init
00212 #pragma weak CG_Fini
00213 #pragma weak CG_PU_Finalize
00214 #pragma weak CG_PU_Initialize
00215 #pragma weak CG_Generate_Code
00216 #pragma weak EH_Generate_Range_List
00217 #pragma weak EH_Dump_INITOs
00218
00219 #endif // __linux__
00220 #endif // SHARED_BUILD
00221
00222 #if defined(TARG_SL) || defined(TARG_MIPS)
00223 extern INT *SI_resource_count_p;
00224 #define SI_resource_count (*SI_resource_count_p)
00225 extern SI_RESOURCE* (*SI_resources_p)[];
00226 #define SI_resources (*SI_resources_p)
00227 extern SI* (*SI_top_si_p)[];
00228 #define SI_top_si (*SI_top_si_p)
00229 extern SI_RRW *SI_RRW_initializer_p;
00230 #define SI_RRW_initializer (*SI_RRW_initializer_p)
00231 extern SI_RRW *SI_RRW_overuse_mask_p;
00232 #define SI_RRW_overuse_mask (*SI_RRW_overuse_mask_p)
00233 extern INT *SI_issue_slot_count_p;
00234 #define SI_issue_slot_count (*SI_issue_slot_count_p)
00235 extern SI_ISSUE_SLOT *(*SI_issue_slots_p)[];
00236 #define SI_issue_slots (*SI_issue_slots_p)
00237 extern INT *SI_ID_count_p;
00238 #define SI_ID_count (*SI_ID_count_p)
00239 extern SI *(*SI_ID_si_p)[];
00240 #define SI_ID_si (*SI_ID_si_p)
00241 #endif // TARG_SL
00242
00243
00244 #if defined(SHARED_BUILD)
00245 #if defined(__linux__) || defined(BUILD_OS_DARWIN)|| defined(__CYGWIN__) || defined(__MINGW32__)
00246
00247 #if !defined(BUILD_FAST_BIN)
00248 extern void (*wopt_main_p) (INT argc, char **argv, INT, char **);
00249 #define wopt_main (*wopt_main_p)
00250
00251 extern void (*Wopt_Init_p) ();
00252 #define Wopt_Init (*Wopt_Init_p)
00253
00254 extern void (*Wopt_Fini_p) ();
00255 #define Wopt_Fini (*Wopt_Fini_p)
00256
00257 extern WN* (*Perform_Preopt_Optimization_p) (WN *, WN *);
00258 #define Perform_Preopt_Optimization (*Perform_Preopt_Optimization_p)
00259
00260 extern WN* (*Perform_Global_Optimization_p) (WN *, WN *, ALIAS_MANAGER *);
00261 #define Perform_Global_Optimization (*Perform_Global_Optimization_p)
00262
00263 extern WN* (*Pre_Optimizer_p) (INT32, WN*, DU_MANAGER*, ALIAS_MANAGER*);
00264 #define Pre_Optimizer (*Pre_Optimizer_p)
00265
00266 extern DU_MANAGER* (*Create_Du_Manager_p) (MEM_POOL *);
00267 #define Create_Du_Manager (*Create_Du_Manager_p)
00268
00269 extern void (*Delete_Du_Manager_p) (DU_MANAGER *, MEM_POOL *);
00270 #define Delete_Du_Manager (*Delete_Du_Manager_p)
00271
00272 extern BOOL (*Verify_alias_p) (ALIAS_MANAGER *, WN *);
00273 #define Verify_alias (*Verify_alias_p)
00274 #else
00275 extern void wopt_main (INT argc, char **argv, INT, char **);
00276 extern void Wopt_Init ();
00277 extern void Wopt_Fini ();
00278 extern WN* Perform_Preopt_Optimization (WN *, WN *);
00279 extern WN* Perform_Global_Optimization (WN *, WN *, ALIAS_MANAGER *);
00280 extern WN* Pre_Optimizer (INT32, WN*, DU_MANAGER*, ALIAS_MANAGER*);
00281 extern DU_MANAGER* Create_Du_Manager (MEM_POOL *);
00282 extern void Delete_Du_Manager (DU_MANAGER *, MEM_POOL *);
00283 extern BOOL Verify_alias (ALIAS_MANAGER *, WN *);
00284 #endif // BUILD_FAST_BIN
00285 #else
00286
00287 #pragma weak wopt_main
00288 #pragma weak Wopt_Init
00289 #pragma weak Wopt_Fini
00290 #pragma weak Perform_Global_Optimization
00291 #pragma weak Perform_Preopt_Optimization
00292 #pragma weak Pre_Optimizer
00293 #pragma weak Create_Du_Manager
00294 #pragma weak Delete_Du_Manager
00295 #pragma weak Verify_alias
00296
00297 #endif // __linux__
00298 #endif // SHARED_BUILD
00299
00300
00301 #ifndef BUILD_SKIP_LNO
00302 #if defined(__linux__) || defined(BUILD_OS_DARWIN)
00303
00304 extern void (*lno_main_p) (INT, char**, INT, char**);
00305 #define lno_main (*lno_main_p)
00306
00307 extern void (*Lno_Init_p) ();
00308 #define Lno_Init (*Lno_Init_p)
00309
00310 extern void (*Lno_Fini_p) ();
00311 #define Lno_Fini (*Lno_Fini_p)
00312
00313 extern WN* (*Perform_Loop_Nest_Optimization_p) (PU_Info*, WN*, WN*, BOOL);
00314 #define Perform_Loop_Nest_Optimization (*Perform_Loop_Nest_Optimization_p)
00315
00316 #else
00317
00318 #pragma weak lno_main
00319 #pragma weak Lno_Init
00320 #pragma weak Lno_Fini
00321 #pragma weak Perform_Loop_Nest_Optimization
00322
00323 #endif // __linux__
00324
00325
00326
00327 #if defined(__linux__) || defined(BUILD_OS_DARWIN)
00328
00329 extern void (*Ipl_Extra_Output_p) (Output_File *);
00330 #define Ipl_Extra_Output (*Ipl_Extra_Output_p)
00331
00332 extern void (*Ipl_Init_p) ();
00333 #define Ipl_Init (*Ipl_Init_p)
00334
00335 extern void (*Ipl_Fini_p) ();
00336 #define Ipl_Fini (*Ipl_Fini_p)
00337
00338 extern void (*ipl_main_p) (INT, char **);
00339 #define ipl_main (*ipl_main_p)
00340
00341 extern void (*Perform_Procedure_Summary_Phase_p) (WN*, DU_MANAGER*,
00342 ALIAS_MANAGER*, void*);
00343 #define Perform_Procedure_Summary_Phase (*Perform_Procedure_Summary_Phase_p)
00344
00345 #ifdef KEY // bug 3672
00346 extern void (*Preprocess_struct_access_p)(void);
00347 #define Preprocess_struct_access (*Preprocess_struct_access_p)
00348 #endif
00349
00350 #else
00351
00352 #pragma weak ipl_main
00353 #pragma weak Ipl_Init
00354 #pragma weak Ipl_Fini
00355 #pragma weak Ipl_Extra_Output
00356 #pragma weak Perform_Procedure_Summary_Phase
00357
00358 #endif // __linux__
00359 #endif // !BUILD_SKIP_LNO
00360
00361 #include "w2c_weak.h"
00362 #include "w2f_weak.h"
00363
00364 #if ! defined(BUILD_OS_DARWIN)
00365 #ifndef BUILD_SKIP_PURPLE
00366 #pragma weak Prp_Process_Command_Line
00367 #pragma weak Prp_Needs_Whirl2c
00368 #pragma weak Prp_Needs_Whirl2f
00369 #pragma weak Prp_Init
00370 #pragma weak Prp_Instrument_And_EmitSrc
00371 #pragma weak Prp_Fini
00372 #endif // !BUILD_SKIP_PURPLE
00373
00374 #ifndef BUILD_SKIP_PROMPF
00375 #pragma weak Anl_Cleanup
00376 #pragma weak Anl_Process_Command_Line
00377 #pragma weak Anl_Needs_Whirl2c
00378 #pragma weak Anl_Needs_Whirl2f
00379 #pragma weak Anl_Init
00380 #pragma weak Anl_Init_Map
00381 #pragma weak Anl_Static_Analysis
00382 #pragma weak Anl_Fini
00383 #endif // !BUILD_SKIP_PROMPF
00384 #endif
00385
00386 #ifdef BUILD_SKIP_LNO
00387 #define Lno_Init() Fail_FmtAssertion("lno not built")
00388 #define Lno_Fini() Fail_FmtAssertion("lno not built")
00389 #define lno_main(a,b,c,d) Fail_FmtAssertion("lno not built")
00390 #define Perform_Loop_Nest_Optimization(a,b,c,d) NULL
00391 #define Ipl_Init() Fail_FmtAssertion("lno not built")
00392 #define Ipl_Fini() Fail_FmtAssertion("lno not built")
00393 #define ipl_main(a,b) Fail_FmtAssertion("lno not built")
00394 #define Perform_Procedure_Summary_Phase(a,b,c,d) Fail_FmtAssertion("lno not built")
00395 #define Preprocess_struct_access() Fail_FmtAssertion("lno not built")
00396 #define Ipl_Extra_Output(a) Fail_FmtAssertion("lno not built")
00397 #endif // BUILD_SKIP_LNO
00398
00399 #ifdef BUILD_SKIP_PURPLE
00400 #define Prp_Process_Command_Line(a,b,c,d) Fail_FmtAssertion("purple not built")
00401 #define Prp_Needs_Whirl2c() FALSE
00402 #define Prp_Needs_Whirl2f() FALSE
00403 #define Prp_Init() Fail_FmtAssertion("purple not built")
00404 #define Prp_Instrument_And_EmitSrc(a) Fail_FmtAssertion("purple not built")
00405 #define Prp_Fini() Fail_FmtAssertion("purple not built")
00406 #endif // BUILD_SKIP_PURPLE
00407
00408 #ifdef BUILD_SKIP_PROMPF
00409 #define Anl_Process_Command_Line(a,b,c,d) Fail_FmtAssertion("prompf not built")
00410 #define Anl_Needs_Whirl2c() FALSE
00411 #define Anl_Needs_Whirl2f() FALSE
00412 #define Anl_Init() Fail_FmtAssertion("prompf not built")
00413 #define Anl_Fini() Fail_FmtAssertion("prompf not built")
00414 #define Anl_Init_Map(a) WN_MAP_UNDEFINED
00415 #define Anl_Static_Analysis(a,b) Fail_FmtAssertion("prompf not built")
00416 #define Prompf_Emit_Whirl_to_Source(a,b) Fail_FmtAssertion("prompf not built")
00417
00418 #else
00419 #ifndef __GNUC__
00420 #pragma weak Prompf_Emit_Whirl_to_Source__GP7pu_infoP2WN
00421 #elif (__GNUC__ == 2)
00422 #pragma weak Prompf_Emit_Whirl_to_Source__FP7pu_infoP2WN
00423 #else
00424 #pragma weak _Z27Prompf_Emit_Whirl_to_SourceP7pu_infoP2WN // gcc 3.2
00425 #endif
00426
00427 extern void Prompf_Emit_Whirl_to_Source(PU_Info* current_pu, WN* func_nd);
00428 #endif // BUILD_SKIP_PROMPF
00429
00430 static INT ecount = 0;
00431 static BOOL need_wopt_output = FALSE;
00432 static BOOL need_lno_output = FALSE;
00433 static BOOL need_ipl_output = FALSE;
00434 static Output_File *ir_output = 0;
00435
00436
00437 static OPTIONS_STACK *Options_Stack;
00438
00439 static BOOL reset_opt_level = FALSE;
00440 static struct ALIAS_MANAGER *alias_mgr = NULL;
00441
00442 static BOOL Run_Distr_Array = FALSE;
00443 BOOL Run_MemCtr = FALSE;
00444
00445 static BOOL Saved_run_prompf = FALSE;
00446 static BOOL Saved_run_w2c = FALSE;
00447 static BOOL Saved_run_w2f = FALSE;
00448 static BOOL Saved_run_w2fc_early = FALSE;
00449
00450 extern WN_MAP Prompf_Id_Map;
00451
00452
00453
00454
00455 static BOOL wopt_loaded = FALSE;
00456 extern BOOL Prompf_anl_loaded;
00457 extern BOOL Purple_loaded;
00458 extern BOOL Whirl2f_loaded;
00459 extern BOOL Whirl2c_loaded;
00460
00461 extern void *Current_Dep_Graph;
00462 FILE *DFile = stderr;
00463
00464 static void
00465 load_components (INT argc, char **argv)
00466 {
00467 INT phase_argc;
00468 char **phase_argv;
00469
00470 if (!(Run_lno || Run_wopt || Run_preopt || Run_cg ||
00471 Run_prompf || Run_purple || Run_w2c || Run_w2f
00472 || Run_w2fc_early || Run_ipl))
00473 Run_cg = TRUE;
00474
00475 if (Run_cg || Run_lno || Run_autopar) {
00476
00477 Initialize_Targ_Info();
00478 }
00479
00480 if (Run_ipl) {
00481 Run_lno = Run_wopt = Run_cg = Run_w2fc_early
00482 = Run_prompf = Run_purple = Run_w2c = Run_w2f = FALSE;
00483 }
00484
00485 if (Run_cg) {
00486 Get_Phase_Args (PHASE_CG, &phase_argc, &phase_argv);
00487 #ifdef TARG_IA64
00488 load_so ("orc_ict.so", CG_Path, Show_Progress);
00489 load_so ("orc_intel.so", CG_Path, Show_Progress);
00490 #endif
00491 #if !defined(BUILD_FAST_BIN)
00492 load_so ("cg.so", CG_Path, Show_Progress);
00493 #endif
00494 CG_Process_Command_Line (phase_argc, phase_argv, argc, argv);
00495 }
00496
00497 if (Run_wopt || Run_preopt || Run_lno || Run_autopar) {
00498 Get_Phase_Args (PHASE_WOPT, &phase_argc, &phase_argv);
00499 #if !defined(BUILD_FAST_BIN)
00500 load_so ("wopt.so", WOPT_Path, Show_Progress);
00501 #endif
00502 wopt_main (phase_argc, phase_argv, argc, argv);
00503 wopt_loaded = TRUE;
00504 }
00505
00506 if (Run_ipl) {
00507 Get_Phase_Args (PHASE_IPL, &phase_argc, &phase_argv);
00508 load_so ("ipl.so", Ipl_Path, Show_Progress);
00509 ipl_main (phase_argc, phase_argv);
00510 Set_Error_Descriptor (EP_BE, EDESC_BE);
00511 }
00512
00513 if (Run_lno || Run_autopar) {
00514 Get_Phase_Args (PHASE_LNO, &phase_argc, &phase_argv);
00515 load_so ("lno.so", LNO_Path, Show_Progress);
00516 lno_main (phase_argc, phase_argv, argc, argv);
00517
00518
00519
00520
00521 if (Run_autopar && LNO_IPA_Enabled) {
00522 load_so("ipl.so", Ipl_Path, Show_Progress);
00523 }
00524 }
00525
00526 if (Run_prompf || Run_w2fc_early) {
00527 Get_Phase_Args (PHASE_PROMPF, &phase_argc, &phase_argv);
00528 load_so("prompf_anl.so", Prompf_Anl_Path, Show_Progress);
00529 Prompf_anl_loaded = TRUE;
00530 Anl_Process_Command_Line(phase_argc, phase_argv, argc, argv);
00531 }
00532
00533 if (Run_purple) {
00534 Get_Phase_Args (PHASE_PURPLE, &phase_argc, &phase_argv);
00535 load_so("purple.so", Purple_Path, Show_Progress);
00536 Purple_loaded = TRUE;
00537 Prp_Process_Command_Line(phase_argc, phase_argv, argc, argv);
00538 }
00539
00540 if (Run_w2c ||
00541 (Run_prompf && Anl_Needs_Whirl2c()) ||
00542 (Run_purple && Prp_Needs_Whirl2c()))
00543 {
00544 Get_Phase_Args (PHASE_W2C, &phase_argc, &phase_argv);
00545 load_so("whirl2c.so", W2C_Path, Show_Progress);
00546 Whirl2c_loaded = TRUE;
00547 if (Run_prompf)
00548 W2C_Set_Prompf_Emission(&Prompf_Id_Map);
00549 W2C_Process_Command_Line(phase_argc, phase_argv, argc, argv);
00550 }
00551
00552 if (Run_w2f ||
00553 (Run_prompf && Anl_Needs_Whirl2f()) ||
00554 (Run_purple && Prp_Needs_Whirl2f()))
00555 {
00556 Get_Phase_Args (PHASE_W2F, &phase_argc, &phase_argv);
00557 load_so("whirl2f.so", W2F_Path, Show_Progress);
00558 Whirl2f_loaded = TRUE;
00559 if (Run_prompf)
00560 W2F_Set_Prompf_Emission(&Prompf_Id_Map);
00561 W2F_Process_Command_Line(phase_argc, (const char**)phase_argv, argc, (const char**)argv);
00562 }
00563 }
00564
00565
00566
00567
00568
00569 static void
00570 Phase_Init (void)
00571 {
00572 char *output_file_name = Obj_File_Name;
00573
00574 if (Run_Distr_Array &&
00575 (Run_w2c || Run_w2f) &&
00576 !Run_lno &&
00577 !Run_wopt &&
00578 !Run_cg)
00579 {
00580
00581
00582
00583
00584
00585 Run_Distr_Array = FALSE;
00586 }
00587 if ( LNO_Run_Lego_Set && ( LNO_Run_Lego == FALSE ) )
00588 Run_Distr_Array = FALSE;
00589
00590 if (Run_cg)
00591 CG_Init ();
00592 if (Run_wopt || Run_preopt)
00593 Wopt_Init ();
00594 if (Run_ipl)
00595 Ipl_Init ();
00596 if (Run_lno || Run_Distr_Array || Run_autopar)
00597 Lno_Init ();
00598 if ( Opt_Level > 0 )
00599 Vho_Init ();
00600 if (Run_purple)
00601 Prp_Init();
00602 if (Run_w2c || (Run_prompf && Anl_Needs_Whirl2c()))
00603 W2C_Outfile_Init (TRUE);
00604 if (Run_w2f || (Run_prompf && Anl_Needs_Whirl2f()))
00605 W2F_Outfile_Init ();
00606 if (Run_prompf)
00607 Anl_Init ();
00608
00609 if ((Run_lno || Run_preopt) && !Run_cg && !Run_wopt)
00610 need_lno_output = TRUE;
00611 if (Run_wopt && !Run_cg)
00612 need_wopt_output = TRUE;
00613
00614 if (Run_ipl) {
00615 need_ipl_output = TRUE;
00616 need_lno_output = need_wopt_output = FALSE;
00617 #ifdef KEY
00618
00619
00620 VHO_Struct_Opt = FALSE;
00621 #endif
00622 }
00623
00624 if (output_file_name == 0) {
00625 if (Src_File_Name)
00626 output_file_name = Last_Pathname_Component (Src_File_Name);
00627 else
00628 output_file_name = Irb_File_Name;
00629 }
00630
00631 if (need_lno_output) {
00632 Write_BE_Maps = TRUE;
00633 ir_output = Open_Output_Info(New_Extension(output_file_name,".N"));
00634 }
00635 if (need_wopt_output) {
00636 Write_ALIAS_CLASS_Map = TRUE;
00637 Write_BE_Maps = TRUE;
00638 ir_output = Open_Output_Info(New_Extension(output_file_name,".O"));
00639 }
00640 if (need_ipl_output) {
00641 Write_BE_Maps = FALSE;
00642 ir_output = Open_Output_Info (Obj_File_Name ?
00643 Obj_File_Name :
00644 New_Extension(output_file_name, ".o"));
00645 }
00646 if (Emit_Global_Data) {
00647 Write_BE_Maps = FALSE;
00648 ir_output = Open_Output_Info (Global_File_Name);
00649 }
00650
00651 if (Run_wopt) {
00652 if (Language != LANG_KR_C) {
00653 Pad_Global_Arrays();
00654 }
00655 }
00656 if ((Run_cg || Run_wopt) && !Read_Global_Data)
00657 Allocate_File_Statics();
00658
00659 }
00660
00661
00662 static void
00663 Phase_Fini (void)
00664 {
00665 CURRENT_SYMTAB = GLOBAL_SYMTAB;
00666
00667
00668 if (Run_prompf)
00669 Anl_Fini();
00670 if (Run_purple)
00671 Prp_Fini();
00672 if (Run_w2c || (Run_prompf && Anl_Needs_Whirl2c()))
00673 W2C_Outfile_Fini (TRUE);
00674 if (Run_w2f || (Run_prompf && Anl_Needs_Whirl2f()))
00675 W2F_Outfile_Fini ();
00676
00677 if (Run_Dsm_Cloner || Run_Dsm_Common_Check)
00678 DRA_Finalize ();
00679
00680 if ( Opt_Level > 0 )
00681 Vho_Fini ();
00682 if (Run_lno || Run_Distr_Array || Run_autopar)
00683 Lno_Fini ();
00684 if (Run_ipl)
00685 Ipl_Fini ();
00686 if (Run_wopt || Run_preopt)
00687 Wopt_Fini ();
00688 if (Run_cg)
00689 CG_Fini ();
00690
00691 Verify_SYMTAB (CURRENT_SYMTAB);
00692 }
00693
00694 char *
00695 Get_Orig_PU_Name (PU_Info * current_pu)
00696 {
00697 DST_IDX dst;
00698 DST_INFO *info;
00699 DST_SUBPROGRAM *PU_attr;
00700
00701 dst = PU_Info_pu_dst(current_pu);
00702
00703 if (DST_IS_NULL (dst)) {
00704 return ST_name(PU_Info_proc_sym(current_pu));
00705 }
00706
00707 info = DST_INFO_IDX_TO_PTR (dst);
00708
00709 if ( (DST_INFO_tag(info) != DW_TAG_subprogram)
00710 || DST_IS_declaration(DST_INFO_flag(info)) )
00711 {
00712 return ST_name(PU_Info_proc_sym(current_pu));
00713 }
00714 PU_attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(info), DST_SUBPROGRAM);
00715 if (PU_attr->def.name.byte_idx < 0) {
00716 return NULL;
00717
00718
00719
00720 }
00721 return DST_STR_IDX_TO_PTR(DST_SUBPROGRAM_def_name(PU_attr));
00722 }
00723
00724 static void
00725 Save_Cur_PU_Name (char *name, INT rid_id)
00726 {
00727 if ( Cur_PU_Name == NULL ) {
00728
00729
00730
00731
00732
00733
00734
00735 Cur_PU_Name = TYPE_MEM_POOL_ALLOC_N(char, &MEM_pu_nz_pool,
00736 strlen(name) + 8);
00737 Cur_PU_Name = strcpy(Cur_PU_Name, name);
00738 }
00739 if (rid_id != 0) {
00740
00741 sprintf(Cur_PU_Name,"%s.RGN%03d", name, rid_id);
00742 }
00743 else if (strlen(name) != strlen(Cur_PU_Name)) {
00744
00745 Cur_PU_Name = strcpy(Cur_PU_Name, name);
00746 }
00747 }
00748
00749
00750
00751
00752
00753
00754 static WN *
00755 Adjust_Opt_Level (PU_Info* current_pu, WN *pu, char *pu_name)
00756 {
00757 INT new_opt_level = 0;
00758 COMPUTE_PU_OLIMIT;
00759
00760 #ifdef KEY
00761
00762 char *p, *demangled_pu_name = pu_name;
00763 BOOL has_demangled_pu_name = FALSE;
00764
00765 if ((PU_src_lang(Get_Current_PU()) & PU_CXX_LANG) &&
00766
00767 pu_name[0] == '_' &&
00768 pu_name[1] == 'Z') {
00769 p = cplus_demangle(pu_name, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES);
00770 if (p) {
00771 demangled_pu_name = p;
00772 has_demangled_pu_name = TRUE;
00773 }
00774 }
00775 #endif
00776
00777 if (Get_Trace(TKIND_INFO, TINFO_STATS)) {
00778
00779 INT PU_Var_Cnt = ST_Table_Size (CURRENT_SYMTAB) +
00780 PREG_Table_Size (CURRENT_SYMTAB);
00781 fprintf (TFile, "PU_Olimit for %s is %d (bbs=%d,stms=%d,vars=%d)\n",
00782 pu_name, PU_Olimit, PU_WN_BB_Cnt, PU_WN_Stmt_Cnt, PU_Var_Cnt);
00783 }
00784
00785 if ((Opt_Level > 0 || Run_autopar) && PU_Olimit > Olimit && !Olimit_opt) {
00786 if (Show_OPT_Warnings)
00787 #ifdef KEY
00788 ErrMsg (EC_Olimit_Exceeded, demangled_pu_name, PU_Olimit);
00789 #else
00790 ErrMsg (EC_Olimit_Exceeded, pu_name, PU_Olimit);
00791 #endif
00792 reset_opt_level = TRUE;
00793 }
00794 if (((Opt_Level > 0 || Run_autopar) || Olimit_opt)
00795 && Query_Skiplist ( Optimization_Skip_List, Current_PU_Count() ) )
00796 {
00797 if (Show_OPT_Warnings)
00798 #ifdef KEY
00799 ErrMsg (EC_Not_Optimized, demangled_pu_name, Current_PU_Count() );
00800 #else
00801 ErrMsg (EC_Not_Optimized, pu_name, Current_PU_Count() );
00802 #endif
00803 reset_opt_level = TRUE;
00804 }
00805 if (
00806
00807
00808 PU_calls_setjmp (Get_Current_PU ())) {
00809 reset_opt_level = TRUE;
00810 new_opt_level = 1;
00811 #ifdef KEY
00812 ErrMsg (EC_Not_Ansi_Setjmp, demangled_pu_name, Current_PU_Count(),
00813 new_opt_level );
00814 #else
00815 ErrMsg (EC_Not_Ansi_Setjmp, pu_name, Current_PU_Count(), new_opt_level );
00816 #endif
00817 }
00818 if (reset_opt_level) {
00819 Opt_Level = new_opt_level;
00820 Run_lno = Run_preopt = Run_wopt = Run_autopar = FALSE;
00821 alias_mgr = NULL;
00822 Olimit_opt = FALSE;
00823 if (Run_prompf)
00824 Prompf_Emit_Whirl_to_Source(current_pu, pu);
00825 }
00826 #ifdef KEY
00827 #define OLIMIT_WARN_THRESHOLD 50000
00828 else if (Opt_Level > 1 && !Olimit_opt &&
00829 (PU_Olimit > OLIMIT_WARN_THRESHOLD) && Show_OPT_Warnings) {
00830 #ifdef KEY
00831 ErrMsg (EC_Olimit_Slow, demangled_pu_name, PU_Olimit);
00832 #else
00833 ErrMsg (EC_Olimit_Slow, pu_name, PU_Olimit);
00834 #endif
00835 }
00836 #endif
00837
00838 if ((PU_Olimit > Olimit) && Olimit_opt) {
00839
00840 pu = Olimit_Region_Insertion (pu, Olimit);
00841
00842
00843
00844
00845
00846
00847 if (Run_lno || Run_Distr_Array || Run_preopt || Run_autopar) {
00848 LNO_Outer_Unroll = 1;
00849 LNO_Fusion = 0;
00850 if (Show_OPT_Warnings)
00851 #ifdef KEY
00852 ErrMsg(EC_LNO_Backoff, demangled_pu_name, LNO_Outer_Unroll,
00853 LNO_Fusion);
00854 #else
00855 ErrMsg(EC_LNO_Backoff, pu_name, LNO_Outer_Unroll, LNO_Fusion);
00856 #endif
00857 }
00858 }
00859
00860 #ifdef KEY
00861 if (has_demangled_pu_name)
00862 free (demangled_pu_name);
00863 #endif
00864
00865 return pu;
00866 }
00867
00868 static void
00869 Ipl_Processing (PU_Info *current_pu, WN *pu)
00870 {
00871 struct DU_MANAGER *du_mgr;
00872 struct ALIAS_MANAGER *al_mgr;
00873
00874 MEM_POOL_Push (&MEM_local_pool);
00875
00876 PU_adjust_addr_flags(Get_Current_PU_ST(), pu);
00877
00878 if (Run_preopt) {
00879 du_mgr = Create_Du_Manager(MEM_pu_nz_pool_ptr);
00880 al_mgr = Create_Alias_Manager(MEM_pu_nz_pool_ptr);
00881 pu = Pre_Optimizer(PREOPT_IPA0_PHASE, pu, du_mgr, al_mgr);
00882 #ifdef Is_True_On
00883 if (Get_Trace (TKIND_ALLOC, TP_IPA)) {
00884 fprintf (TFile, "\n%s%s\tMemory allocation information after"
00885 " IPA local pre_opt\n%s%s\n", DBar, DBar, DBar, DBar);
00886 MEM_Trace ();
00887 }
00888 #endif
00889 Delete_Alias_Manager (al_mgr, MEM_pu_nz_pool_ptr);
00890 Delete_Du_Manager (du_mgr, MEM_pu_nz_pool_ptr);
00891 } else {
00892 Set_Error_Phase ( "IPA Summary" );
00893 Perform_Procedure_Summary_Phase (pu, du_mgr, al_mgr, 0);
00894 }
00895
00896
00897 Set_PU_Info_tree_ptr(current_pu, pu);
00898
00899 Write_PU_Info (current_pu);
00900
00901 MEM_POOL_Pop (&MEM_local_pool);
00902
00903 }
00904
00905
00906
00907
00908 static WN *
00909 LNO_Processing (PU_Info *current_pu, WN *pu)
00910 {
00911 REGION_CS_ITER rgn_iter;
00912
00913 REGION_CS_ITER_init(&rgn_iter, pu);
00914
00915
00916
00917 for (REGION_CS_NoEarlierSub_First(&rgn_iter, pu, RID_TYPE_func_entry);
00918 REGION_CS_NoEarlierSub_While(&rgn_iter);
00919 REGION_CS_NoEarlierSub_Next(&rgn_iter)) {
00920
00921 WN *rwn;
00922
00923 rwn = REGION_remove_and_mark(pu, &rgn_iter);
00924 Is_True(rwn != NULL,
00925 ("BE driver, IR inconsistency, LNO loop"));
00926 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
00927 fprintf(TFile,"===== BE driver, LNO loop: %s %d, stacked=%d\n",
00928 REGION_CS_ITER_is_pu(&rgn_iter) ? "PU" : "RGN",
00929 RID_id(REGION_get_rid(rwn)),
00930 !REGION_CS_ITER_is_not_stacked(&rgn_iter));
00931 RID_WN_Tree_Print(TFile, rwn);
00932 }
00933
00934
00935
00936
00937 BOOL is_mp = PU_mp (Get_Current_PU ());
00938 BOOL needs_lno = PU_mp_needs_lno (Get_Current_PU ());
00939
00940 if (!is_mp || Early_MP_Processing) {
00941 if (Run_lno || Run_autopar || (Run_Distr_Array && needs_lno)) {
00942
00943 if (Early_MP_Processing && is_mp) {
00944 Free_Dep_Graph();
00945 Current_Dep_Graph = PU_Info_depgraph_ptr(Current_PU_Info);
00946 }
00947 rwn = Perform_Loop_Nest_Optimization(current_pu, pu, rwn,
00948 TRUE );
00949 Set_PU_Info_depgraph_ptr(Current_PU_Info,Current_Dep_Graph);
00950 if (Current_Dep_Graph) {
00951 Set_PU_Info_state(Current_PU_Info,WT_DEPGRAPH,Subsect_InMem);
00952 } else {
00953 Set_PU_Info_state(Current_PU_Info,WT_DEPGRAPH,Subsect_Missing);
00954 }
00955
00956 Check_for_IR_Dump(TP_LNOPT, rwn, "LNO");
00957 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
00958 fprintf(TFile,"===== After LNO, %s %d, stacked=%d\n",
00959 REGION_CS_ITER_is_pu(&rgn_iter) ? "PU" : "RGN",
00960 RID_id(REGION_get_rid(rwn)),
00961 !REGION_CS_ITER_is_not_stacked(&rgn_iter));
00962 RID_WN_Tree_Print(TFile, rwn);
00963 fdump_tree(TFile, rwn);
00964 RID_set_print(TFile,REGION_get_rid(rwn));
00965 }
00966 } else if (Run_preopt) {
00967 rwn = Perform_Preopt_Optimization(pu, rwn);
00968 Check_for_IR_Dump(TP_GLOBOPT, rwn, "PREOPT");
00969 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
00970 fprintf(TFile,"===== After PREOPT (:p), %s %d, stacked=%d\n",
00971 REGION_CS_ITER_is_pu(&rgn_iter) ? "PU" : "RGN",
00972 RID_id(REGION_get_rid(rwn)),
00973 !REGION_CS_ITER_is_not_stacked(&rgn_iter));
00974 RID_WN_Tree_Print(TFile, rwn);
00975 fdump_tree(TFile, rwn);
00976 RID_set_print(TFile,REGION_get_rid(rwn));
00977 }
00978 }
00979 } else {
00980 Free_Dep_Graph();
00981 Current_Dep_Graph = PU_Info_depgraph_ptr(Current_PU_Info);
00982 }
00983
00984 if (REGION_CS_ITER_is_not_stacked(&rgn_iter))
00985 pu = rwn;
00986 REGION_replace_from_mark(rwn, &rgn_iter);
00987
00988 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
00989 fprintf(TFile,"------------ bottom of LNO loop: -----------\n");
00990 REGION_consistency_check(pu);
00991 RID_WN_Tree_Print(TFile,pu);
00992 if (Run_cg)
00993 fdump_region_tree(TFile,pu);
00994 else
00995 fdump_tree(TFile,pu);
00996 fprintf(TFile,"--------------------------------------------\n");
00997 }
00998 }
00999
01000 return pu;
01001 }
01002
01003
01004
01005
01006 static void
01007 Post_LNO_Processing (PU_Info *current_pu, WN *pu)
01008 {
01009 BOOL is_user_visible_pu = (CURRENT_SYMTAB == GLOBAL_SYMTAB + 1) ||
01010 ((Language == LANG_F90) &&
01011 (CURRENT_SYMTAB == GLOBAL_SYMTAB + 2) &&
01012 (!Is_Set_PU_Info_flags(current_pu, PU_IS_COMPILER_GENERATED))) ;
01013
01014
01015
01016 if (Run_w2c && !Run_w2fc_early && !Run_prompf) {
01017 if (W2C_Should_Emit_Nested_PUs() || is_user_visible_pu) {
01018 if (Cur_PU_Feedback)
01019 W2C_Set_Frequency_Map(WN_MAP_FEEDBACK);
01020 W2C_Outfile_Translate_Pu(pu, TRUE);
01021 }
01022 }
01023 if (Run_w2f && !Run_w2fc_early && !Run_prompf) {
01024 if (W2F_Should_Emit_Nested_PUs() || is_user_visible_pu) {
01025 if (Cur_PU_Feedback)
01026 W2F_Set_Frequency_Map(WN_MAP_FEEDBACK);
01027 W2F_Outfile_Translate_Pu(pu);
01028 }
01029 }
01030
01031
01032
01033 if (need_lno_output) {
01034 Set_PU_Info_tree_ptr(current_pu, pu);
01035 Write_PU_Info(current_pu);
01036 Verify_SYMTAB (CURRENT_SYMTAB);
01037 }
01038 }
01039
01040 static WN *
01041 WOPT_Processing (PU_Info *current_pu, WN *pu, REGION_CS_ITER *rgn_iter,
01042 WN *rwn)
01043 {
01044 rwn = Perform_Global_Optimization (pu, rwn, alias_mgr);
01045 Check_for_IR_Dump(TP_GLOBOPT, rwn, "WOPT");
01046 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01047 fprintf(TFile, "===== driver, after Perform_Global_Optimization");
01048 fprintf(TFile," RGN %d =====\n", RID_id(REGION_get_rid(rwn)));
01049 RID_WN_Tree_Print(TFile,pu);
01050 fdump_tree(TFile,rwn);
01051 fprintf(TFile,"===== driver ---------------------\n");
01052 fprintf(TFile,"#### Verify_alias, after mainopt, RGN %d\n",
01053 RID_id(REGION_get_rid(rwn)));
01054 Verify_alias(alias_mgr, rwn);
01055 if (Run_cg)
01056 fdump_region_tree(TFile,rwn);
01057 fprintf(TFile,"#### Verify_alias, done\n");
01058 }
01059
01060 return rwn;
01061 }
01062
01063
01064 static WN *
01065 Do_WOPT_and_CG_with_Regions (PU_Info *current_pu, WN *pu)
01066 {
01067 REGION_CS_ITER rgn_iter;
01068 BOOL Run_region_bounds;
01069 BOOL cg_one_time = TRUE;
01070
01071
01072 Initialize_Stack_Frame (pu);
01073
01074
01075 { RID *rid = REGION_get_rid(pu);
01076 Is_True(rid != NULL && RID_TYPE_func_entry(rid) && RID_id(rid) == 0,
01077 ("Do_WOPT_and_CG_with_Regions, RID is incorrect"));
01078 Run_region_bounds = RID_contains_bounds(rid);
01079 Is_Trace(Get_Trace(TP_REGION, TT_REGION_CG_DEBUG) ||
01080 Get_Trace(TP_REGION, TT_REGION_BOUND_DEBUG),
01081 (TFile,"Driver, RID_contains_bounds(%s) = %c\n",
01082 ST_name(PU_Info_proc_sym(current_pu)),
01083 Run_region_bounds ? 'T' : 'F'));
01084 }
01085
01086
01087
01088
01089
01090 if ((Run_wopt || Run_region_bounds) && alias_mgr == 0)
01091 alias_mgr = Create_Alias_Manager(MEM_pu_nz_pool_ptr);
01092
01093
01094 if (Run_region_bounds) {
01095 Set_Error_Phase("Generate Region Boundaries");
01096 Generate_region_boundaries(pu, alias_mgr);
01097 }
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108 REGION_CS_ITER_init(&rgn_iter, pu);
01109 for (REGION_CS_NoEarlierSub_First(&rgn_iter, pu,
01110 (RID_TYPE)(RID_TYPE_olimit | RID_TYPE_pragma | RID_TYPE_loop));
01111 REGION_CS_NoEarlierSub_While(&rgn_iter);
01112 REGION_CS_NoEarlierSub_Next(&rgn_iter)) {
01113 WN *rwn;
01114 BOOL need_options_pop = FALSE;
01115
01116 rwn = REGION_remove_and_mark(pu, &rgn_iter);
01117
01118 Is_True(rwn != NULL, ("BE driver, IR inconsistency, WOPT-CG loop"));
01119 Is_True(REGION_get_rid(rwn) != NULL, ("BE driver, NULL RID"));
01120 Is_True(RID_type(REGION_get_rid(rwn)) != RID_TYPE_undefined,
01121 ("BE driver, undefined RID type"));
01122
01123 Set_Current_Region_For_Trace( RID_id(REGION_get_rid(rwn)) );
01124
01125 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01126 fprintf(TFile,"===== BE driver, WOPT-CG loop: %s %d, stacked=%d\n",
01127 REGION_CS_ITER_is_pu(&rgn_iter) ? "PU" : "RGN",
01128 RID_id(REGION_get_rid(rwn)),
01129 !REGION_CS_ITER_is_not_stacked(&rgn_iter));
01130 RID_WN_Tree_Print(TFile, rwn);
01131 }
01132
01133 #ifndef KEY
01134
01135 { RID *rid = REGION_get_rid(rwn);
01136 Is_True(rid != NULL, ("BE driver, NULL rid inside region loop"));
01137 if (RID_options(rid) != NULL) {
01138 Options_Stack->Process_Pragma_Options(RID_options(rid));
01139 need_options_pop = TRUE;
01140 }
01141 }
01142 #endif
01143
01144 if (Show_Progress) {
01145 if (rwn != pu)
01146 fprintf(stderr, "... compiling region (%d)\n",
01147 RID_id(REGION_get_rid(rwn)));
01148 else if (!cg_one_time)
01149 fprintf(stderr, "... compiling program unit\n");
01150 }
01151
01152 Save_Cur_PU_Name (ST_name(PU_Info_proc_sym(current_pu)),
01153 RID_id(REGION_get_rid(rwn)));
01154
01155
01156 if (Instrumentation_Enabled
01157 && (Instrumentation_Type_Num & WHIRL_PROFILE)
01158 && (Instrumentation_Phase_Num == PROFILE_PHASE_BEFORE_WOPT)) {
01159 WN_Instrument(rwn, PROFILE_PHASE_BEFORE_WOPT);
01160 } else if (Feedback_Enabled[PROFILE_PHASE_BEFORE_WOPT]) {
01161 WN_Annotate(rwn, PROFILE_PHASE_BEFORE_WOPT, &MEM_pu_pool);
01162 }
01163 Set_Error_Phase ( "Before WOPT" );
01164
01165 if (Run_wopt) {
01166 rwn = WOPT_Processing (current_pu, pu, &rgn_iter, rwn);
01167 if (WN_opcode(rwn) == OPC_FUNC_ENTRY)
01168 Verify_SYMTAB (CURRENT_SYMTAB);
01169 if ( Cur_PU_Feedback ) {
01170 Cur_PU_Feedback->Verify("after WOPT");
01171 }
01172 #if 0 // this is now unnecessary because the lowering is done inside wopt
01173 if (Only_Unsigned_64_Bit_Ops && Delay_U64_Lowering)
01174 U64_lower_wn(rwn, FALSE);
01175 #endif
01176 }
01177
01178
01179
01180
01181
01182 if (need_wopt_output && REGION_CS_ITER_is_not_stacked(&rgn_iter)) {
01183 Set_PU_Info_tree_ptr(current_pu, rwn);
01184 Write_PU_Info(current_pu);
01185 }
01186
01187
01188
01189 Save_Cur_PU_Name (ST_name(PU_Info_proc_sym(current_pu)),
01190 RID_id(REGION_get_rid(rwn)));
01191
01192
01193 if (Instrumentation_Enabled
01194 && (Instrumentation_Type_Num & WHIRL_PROFILE)
01195 && (Instrumentation_Phase_Num == PROFILE_PHASE_BEFORE_CG)) {
01196 rwn = WN_Lower(rwn, LOWER_SCF, NULL,
01197 "Lower structured control flow");
01198 WN_Instrument(rwn, PROFILE_PHASE_BEFORE_CG);
01199 #if 0
01200 extern void wb_gwe(WN*);
01201 wb_gwe(rwn);
01202 #endif
01203 } else if (Feedback_Enabled[PROFILE_PHASE_BEFORE_CG]) {
01204 rwn = WN_Lower(rwn, LOWER_SCF, NULL,
01205 "Lower structured control flow");
01206 WN_Annotate(rwn, PROFILE_PHASE_BEFORE_CG, &MEM_pu_pool);
01207 }
01208 Set_Error_Phase ( "Before CG" );
01209
01210 if (Run_cg) {
01211 Set_Error_Phase ("Lowering");
01212 WB_LWR_Initialize(rwn, alias_mgr);
01213
01214
01215 if (!Run_wopt ||
01216
01217 Query_Skiplist (WOPT_Skip_List, Current_PU_Count()) ) {
01218
01219 rwn = WN_Lower(rwn, LOWER_MLDID_MSTID, alias_mgr,
01220 "Lower MLDID/MSTID when not running WOPT");
01221 #ifdef KEY // bug 7298: this flag could have been set by LNO's preopt
01222 Clear_BE_ST_pu_has_valid_addr_flags(PU_Info_proc_sym(current_pu));
01223 #endif
01224 }
01225
01226 #if defined(EMULATE_FLOAT_POINT) && defined(TARG_SL)
01227 rwn = WN_Lower(rwn, LOWER_TO_CG | LOWER_FP_EMULATE, alias_mgr, "Lowering to CG/Lowering float point emulate");
01228 #else
01229 rwn = WN_Lower(rwn, LOWER_TO_CG, alias_mgr, "Lowering to CG");
01230 #endif
01231 #ifdef TARG_IA64
01232 if (Only_Unsigned_64_Bit_Ops &&
01233 (!Run_wopt || Query_Skiplist (WOPT_Skip_List, Current_PU_Count()))) U64_lower_wn(rwn, FALSE);
01234 #endif
01235 WB_LWR_Terminate();
01236 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01237 fprintf(TFile,"===== driver, after lowering\n");
01238 RID_WN_Tree_Print(TFile,rwn);
01239 }
01240
01241 #ifdef TARG_NVISA
01242
01243
01244
01245 Set_BE_ST_pu_needs_addr_flag_adjust(Get_Current_PU_ST());
01246 PU_adjust_addr_flags(Get_Current_PU_ST(), rwn);
01247 #endif
01248
01249 if ( Cur_PU_Feedback ) {
01250 Cur_PU_Feedback->Verify("after LOWER_TO_CG");
01251 }
01252
01253 if (cg_one_time) {
01254 cg_one_time = FALSE;
01255
01256 Set_Error_Phase("Data Layout");
01257
01258 Calculate_Stack_Frame_Sizes (rwn);
01259 CG_PU_Initialize(pu);
01260 }
01261
01262 if (!REGION_CS_ITER_is_not_stacked(&rgn_iter) ||
01263 !REGION_CS_ITER_is_pu(&rgn_iter)) {
01264 DST_IDX tmp_idx;
01265 WN *compiled_block;
01266 tmp_idx.byte_idx = DST_INVALID_BYTE_IDX;
01267 FmtAssert(PU_has_region (Get_Current_PU ()),
01268 ("BE driver, found region when SYMTAB_has_rgn is off"));
01269 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01270 fprintf(TFile,
01271 "===== driver, before CG_Generate_Code (region)\n");
01272 RID_WN_Tree_Print(TFile,rwn);
01273 RID_set_print(TFile,REGION_get_rid(rwn));
01274 }
01275 compiled_block = CG_Generate_Code(rwn, alias_mgr, tmp_idx, TRUE);
01276 rwn = compiled_block;
01277 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01278 fprintf(TFile,
01279 "===== driver, after CG_Generate_Code\n");
01280 RID_WN_Tree_Print(TFile,rwn);
01281 }
01282 }
01283 }
01284
01285 if (REGION_CS_ITER_is_not_stacked(&rgn_iter))
01286 pu = rwn;
01287 REGION_replace_from_mark(rwn, &rgn_iter);
01288
01289 if (need_options_pop)
01290 Options_Stack->Pop_Current_Options();
01291 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01292 fprintf(TFile,
01293 "------------ bottom of WOPT-CG loop: ------------\n");
01294 Is_True(REGION_consistency_check(pu),(""));
01295 RID_WN_Tree_Print(TFile,pu);
01296 if (Run_cg)
01297 fdump_region_tree(TFile,pu);
01298 else
01299 fdump_tree(TFile,pu);
01300 fprintf(TFile,"--------------------------------------------\n");
01301 }
01302 if (rwn != pu)
01303 Report_CG_Region_Timing ( Tim_File, Cur_PU_Name );
01304 }
01305 Verify_SYMTAB (CURRENT_SYMTAB);
01306 return pu;
01307 }
01308
01309
01310 static void
01311 Post_Process_Backend (PU_Info *current_pu, WN *pu)
01312 {
01313 if (Run_cg) {
01314 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01315 fprintf(TFile,"BE driver, Post_Process_Backend "
01316 "+++++++++++++++++++++++++++++++\n");
01317 RID_WN_Tree_Print(TFile,pu);
01318 fdump_region_tree(TFile,pu);
01319 fprintf(TFile,"BE driver, Post_Process_Backend "
01320 "+++++++++++++++++++++++++++++++\n");
01321 fprintf(TFile,"Right before CG_Generate_Code (PU)\n");
01322 }
01323
01324 CG_Generate_Code(pu, alias_mgr, PU_Info_pu_dst(current_pu), FALSE);
01325 CG_PU_Finalize();
01326 }
01327
01328 if (alias_mgr) {
01329 Delete_Alias_Manager(alias_mgr, MEM_pu_nz_pool_ptr);
01330 alias_mgr = NULL;
01331 }
01332 }
01333
01334
01335
01336 extern "C" {
01337 extern void Process_Fill_Align_Pragmas (WN* func_wn);
01338 extern void Rewrite_Pragmas_On_Structs (WN* block_wn, WN* wn);
01339 }
01340
01341
01342
01343
01344
01345
01346 static void Update_EHRegion_Inito_Used (WN *wn) {
01347 if (!wn) return;
01348
01349 OPERATOR opr = WN_operator(wn);
01350
01351 if (opr == OPR_REGION && WN_ereg_supp(wn)) {
01352 INITO_IDX ino_idx = WN_ereg_supp(wn);
01353 #ifdef TARG_IA64
01354
01355
01356
01357
01358 if (INITV_kind(INITO_val(ino_idx)) != INITVKIND_LABEL){
01359 ST *st = INITO_st(ino_idx);
01360 Clear_ST_is_not_used(st);
01361 }
01362 #else
01363 ST *st = INITO_st(ino_idx);
01364 Clear_ST_is_not_used(st);
01365 #endif
01366 }
01367
01368
01369 if (opr == OPR_BLOCK) {
01370 WN *kid = WN_first (wn);
01371 while (kid) {
01372 Update_EHRegion_Inito_Used(kid);
01373 kid = WN_next(kid);
01374 }
01375 } else {
01376 for (INT kidno=0; kidno<WN_kid_count(wn); kidno++) {
01377 Update_EHRegion_Inito_Used(WN_kid(wn,kidno));
01378 }
01379 }
01380 }
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390 static void Update_EHRegion_Inito (WN *pu) {
01391 INT i;
01392 INITO *ino;
01393
01394
01395
01396
01397
01398
01399 FOREACH_INITO (CURRENT_SYMTAB, ino, i) {
01400 ST *st = INITO_st(ino);
01401 if (ST_sclass(st) == SCLASS_EH_REGION ||
01402 ST_sclass(st) == SCLASS_EH_REGION_SUPP) {
01403 Set_ST_is_not_used(st);
01404 }
01405 }
01406
01407
01408
01409
01410 Update_EHRegion_Inito_Used (pu);
01411 }
01412
01413 static void
01414 Backend_Processing (PU_Info *current_pu, WN *pu)
01415 {
01416 {
01417
01418
01419
01420
01421 static BOOL done_first_pu = FALSE;
01422 BOOL needs_fill_align_lowering =
01423 PU_needs_fill_align_lowering (Get_Current_PU ());
01424 if (needs_fill_align_lowering || !done_first_pu) {
01425 Process_Fill_Align_Pragmas (pu);
01426 done_first_pu = TRUE;
01427 }
01428 }
01429
01430 #ifdef KEY
01431 BOOL need_options_pop = FALSE;
01432
01433
01434 WN *block = WN_func_pragmas(pu);
01435 for (WN *pragwn = WN_first(block); pragwn; pragwn = WN_next(pragwn))
01436 if (WN_pragma(pragwn) == WN_PRAGMA_OPTIONS) {
01437 ST *st = WN_st(pragwn);
01438 TCON *tc = &Tcon_Table[ST_tcon (st)];
01439 Options_Stack->Process_Pragma_Options(Targ_String_Address(*tc));
01440 need_options_pop = TRUE;
01441 }
01442 #endif
01443
01444 PU_adjust_addr_flags(Get_Current_PU_ST(), pu);
01445
01446 if (Run_MemCtr)
01447 MemCtr_Add (pu);
01448
01449
01450
01451
01452
01453 if (WHIRL_Return_Val_On || WHIRL_Mldid_Mstid_On) {
01454 Is_True(WHIRL_Return_Val_On && WHIRL_Mldid_Mstid_On,
01455 ("-INTERNAL:return_val and -INTERNAL:mldid_mstid must be on the same time"));
01456 pu = WN_Lower (pu, LOWER_RETURN_VAL, NULL,
01457 "RETURN_VAL & MLDID/MSTID lowering");
01458 }
01459
01460 #ifdef KEY // bug 9171
01461 if (Run_autopar && Early_MP_Processing) {
01462 Early_MP_Processing = FALSE;
01463 ErrMsg (EC_No_Apo_Early_Mp);
01464 }
01465 #endif
01466
01467
01468
01469 BOOL has_mp = PU_has_mp (Get_Current_PU ());
01470 if (has_mp && Early_MP_Processing) {
01471 Set_PU_Info_depgraph_ptr(Current_PU_Info,Current_Dep_Graph);
01472 Set_PU_Info_state(Current_PU_Info,WT_DEPGRAPH,Subsect_InMem);
01473
01474 Set_Error_Phase ( "MP Lowering" );
01475 WB_LWR_Initialize(pu, NULL);
01476 pu = WN_Lower (pu, LOWER_MP, NULL, "Before MP Lowering");
01477
01478 #ifdef KEY
01479 extern void Post_MP_Processing (WN *);
01480 Post_MP_Processing (PU_Info_tree_ptr(Current_PU_Info));
01481 #endif
01482 WB_LWR_Terminate();
01483 }
01484
01485
01486 WN_MEMOP_ANNOT_MGR_Constructor mem_annot_mgr;
01487
01488
01489 if( Instrumentation_Enabled
01490 && (Instrumentation_Type_Num & WHIRL_PROFILE)
01491 && (Instrumentation_Phase_Num == PROFILE_PHASE_BEFORE_LNO)) {
01492 WN_Instrument(pu, PROFILE_PHASE_BEFORE_LNO);
01493 } else if ( Feedback_Enabled[PROFILE_PHASE_BEFORE_LNO] ) {
01494 WN_Annotate(pu, PROFILE_PHASE_BEFORE_LNO, &MEM_pu_pool);
01495 }
01496 Set_Error_Phase ( "LNO Processing" );
01497
01498 if (Run_lno || Run_Distr_Array || Run_preopt || Run_autopar) {
01499 #ifdef KEY // to avoid assertion in PU that represents file-scope asm statement
01500 if (! (WN_operator(pu) == OPR_FUNC_ENTRY &&
01501 ST_asm_function_st(*WN_st(pu))))
01502 #endif
01503 pu = LNO_Processing (current_pu, pu);
01504 #ifndef KEY
01505
01506
01507
01508 if (Run_autopar)
01509 Rewrite_Pragmas_On_Structs (NULL, WN_func_body(pu));
01510 #endif
01511 }
01512
01513
01514 Set_Error_Phase ( "Post LNO Processing" );
01515 Post_LNO_Processing (current_pu, pu);
01516 if (!Run_wopt && !Run_cg) return;
01517
01518 #ifdef KEY // bug 7741
01519 if (Run_lno && Run_wopt) {
01520
01521
01522
01523 Clear_local_symtab_addr_flags(Scope_tab[CURRENT_SYMTAB]);
01524 Recompute_addr_saved_stmt (pu);
01525 if (!PU_ftn_lang (Get_Current_PU()))
01526 Set_addr_saved_stmt(pu, CXX_Alias_Const ||
01527 (OPT_IPA_addr_analysis && PU_ipa_addr_analysis(Get_Current_PU())));
01528 }
01529 #endif
01530
01531 Verify_SYMTAB (CURRENT_SYMTAB);
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543 has_mp = PU_has_mp (Get_Current_PU ());
01544 if (has_mp && !Early_MP_Processing) {
01545 Set_Error_Phase ( "MP Lowering" );
01546 WB_LWR_Initialize(pu, NULL);
01547 pu = WN_Lower (pu, LOWER_MP, NULL, "Before MP Lowering");
01548 #ifdef KEY
01549
01550 extern void Post_MP_Processing (WN *);
01551 Post_MP_Processing (PU_Info_tree_ptr(Current_PU_Info));
01552 #endif
01553 WB_LWR_Terminate();
01554 }
01555
01556 #ifdef KEY
01557 if (PU_cxx_lang (Get_Current_PU()))
01558 #endif
01559 Update_EHRegion_Inito (pu);
01560
01561 #if defined(TARG_IA64)
01562
01563
01564
01565
01566 if (Get_Trace (TP_EH, 0x0004)) {
01567 fprintf (TFile, "=======================================================================\n");
01568 fprintf (TFile, "\t Used EH INITO info for PU: %s \t\n",
01569 ST_name (current_pu->proc_sym));
01570 fprintf (TFile, "\t (After Update_EHRegion_Inito) \t\n");
01571 fprintf (TFile, "=======================================================================\n");
01572 EH_Dump_INITOs (pu, TFile);
01573 }
01574 #endif
01575
01576 if (Run_cg)
01577 EH_Generate_Range_List(pu);
01578
01579 BOOL save_run_wopt = Run_wopt;
01580
01581
01582
01583 if (Run_wopt &&
01584 (WN_operator(pu) == OPR_FUNC_ENTRY) &&
01585 ST_asm_function_st(*WN_st(pu))) {
01586
01587
01588 Run_wopt = FALSE;
01589 }
01590
01591 Set_Error_Phase ( "WOPT/CG Processing" );
01592 pu = Do_WOPT_and_CG_with_Regions (current_pu, pu);
01593
01594 Run_wopt = save_run_wopt;
01595
01596 Set_Error_Phase ( "Post Backend Processing" );
01597 Post_Process_Backend (current_pu, pu);
01598
01599 #ifdef KEY
01600 if (need_options_pop)
01601 Options_Stack->Pop_Current_Options();
01602 #endif
01603 #ifdef KEY // bug 9651
01604 WN_Reset_Num_Delete_Cleanup_Fns();
01605 #endif
01606 }
01607
01608 #if defined(TARG_SL)
01609 BOOL Walk_And_Insert_Init_Buf(WN* wn, WN* block)
01610 {
01611 OPERATOR opr=WN_operator(wn);
01612 if( opr == OPR_PRAGMA && WN_pragma( wn ) == WN_PRAGMA_PREAMBLE_END ) {
01613 TY_IDX ty;
01614 ST *st;
01615
01616 ty = Make_Function_Type( MTYPE_To_TY( MTYPE_V ) );
01617
01618 if(Sl2_Ibuf_Name==NULL)
01619 st = Gen_Intrinsic_Function( ty, "cmp_init_sl_buf" );
01620 else
01621 st = Gen_Intrinsic_Function( ty, Sl2_Ibuf_Name );
01622
01623 Clear_PU_no_side_effects( Pu_Table[ST_pu( st )] );
01624 Clear_PU_is_pure( Pu_Table[ST_pu( st )] );
01625 Set_PU_no_delete( Pu_Table[ST_pu( st )] );
01626
01627 WN *call_initbuf = WN_Call( MTYPE_V, MTYPE_V, 0, st );
01628 WN_Set_Call_Default_Flags(call_initbuf );
01629 WN_INSERT_BlockBefore(block, wn, call_initbuf);
01630 return TRUE;
01631 }
01632 else if(opr==OPR_BLOCK) {
01633 for ( WN* stmt = WN_first( wn ); stmt; stmt = WN_next( wn) )
01634 if(Walk_And_Insert_Init_Buf( stmt, wn ))
01635 return TRUE;
01636 }
01637 else {
01638 for ( INT32 i = 0; i < WN_kid_count( wn ); i++ )
01639 if(Walk_And_Insert_Init_Buf( WN_kid( wn, i ), wn ))
01640 return TRUE;
01641 }
01642 return FALSE;
01643
01644 }
01645 #endif
01646
01647 static WN *
01648 Preprocess_PU (PU_Info *current_pu)
01649 {
01650 WN *pu = NULL;
01651
01652 Initialize_PU_Stats ();
01653
01654 Current_PU_Info = current_pu;
01655 MEM_POOL_Push(MEM_pu_nz_pool_ptr);
01656 MEM_POOL_Push(MEM_pu_pool_ptr);
01657
01658 Cur_PU_Feedback = NULL;
01659
01660 BOOL is_mp_nested_pu = FALSE;
01661
01662
01663 Start_Timer ( T_ReadIR_CU );
01664
01665
01666
01667 if (PU_Info_state (current_pu, WT_TREE) != Subsect_InMem) {
01668 Read_Local_Info (MEM_pu_nz_pool_ptr, current_pu);
01669 if (PU_Info_state (current_pu, WT_FEEDBACK) == Subsect_InMem) {
01670 const Pu_Hdr* pu_hdr = (const Pu_Hdr*)
01671 PU_Info_feedback_ptr (current_pu);
01672 #ifdef KEY
01673 Cur_PU_Feedback = CXX_NEW (FEEDBACK (PU_Info_tree_ptr (current_pu),
01674 MEM_pu_nz_pool_ptr,
01675 pu_hdr->pu_num_inv_entries,
01676 pu_hdr->pu_num_br_entries,
01677 pu_hdr->pu_num_loop_entries,
01678 pu_hdr->pu_num_scircuit_entries,
01679 pu_hdr->pu_num_call_entries,
01680 pu_hdr->pu_num_icall_entries,
01681 pu_hdr->pu_num_switch_entries,
01682 pu_hdr->pu_num_value_entries,
01683 pu_hdr->pu_num_value_fp_bin_entries,
01684 pu_hdr->runtime_fun_address),
01685 MEM_pu_nz_pool_ptr);
01686 #else
01687 Cur_PU_Feedback = CXX_NEW (FEEDBACK (PU_Info_tree_ptr (current_pu),
01688 MEM_pu_nz_pool_ptr,
01689 pu_hdr->pu_num_inv_entries,
01690 pu_hdr->pu_num_br_entries,
01691 pu_hdr->pu_num_loop_entries,
01692 pu_hdr->pu_num_scircuit_entries,
01693 pu_hdr->pu_num_call_entries,
01694 pu_hdr->pu_num_icall_entries,
01695 pu_hdr->pu_num_switch_entries),
01696 MEM_pu_nz_pool_ptr);
01697 #endif
01698 Read_Feedback_Info (Cur_PU_Feedback, PU_Info_tree_ptr (current_pu),
01699 *pu_hdr);
01700
01701 Instrumentation_Enabled = FALSE;
01702 BZERO (Feedback_Enabled, (PROFILE_PHASE_LAST-1) * sizeof(BOOL));
01703 } else
01704 Cur_PU_Feedback = NULL;
01705 } else {
01706
01707 Current_Map_Tab = PU_Info_maptab(current_pu);
01708 Current_pu = &PU_Info_pu(current_pu);
01709 CURRENT_SYMTAB = PU_lexical_level(*Current_pu);
01710 if ((PU_is_nested_func(*Current_pu) && PU_mp(*Current_pu)) ||
01711 Is_Set_PU_Info_flags(current_pu, PU_IS_DRA_CLONE)) {
01712 is_mp_nested_pu = TRUE;
01713
01714 Restore_Local_Symtab(current_pu);
01715
01716 if (PU_Info_state (current_pu, WT_FEEDBACK) == Subsect_InMem) {
01717
01718 Cur_PU_Feedback = (FEEDBACK *) PU_Info_feedback_ptr (current_pu);
01719 Is_True(Cur_PU_Feedback, ("invalid PU_Info for feedback"));
01720
01721 Instrumentation_Enabled = FALSE;
01722 BZERO(Feedback_Enabled, (PROFILE_PHASE_LAST-1) * sizeof(BOOL));
01723 } else
01724 Cur_PU_Feedback = NULL;
01725 #ifdef KEY
01726 } else if (Is_Set_PU_Info_flags(current_pu, PU_IS_PROFILER)) {
01727 Restore_Local_Symtab(current_pu);
01728 Cur_PU_Feedback = NULL;
01729 #endif
01730 } else {
01731 Is_True(FALSE, ("Robert doesn't understand where symtabs come from"));
01732 }
01733 }
01734
01735 BE_symtab_alloc_scope_level(CURRENT_SYMTAB);
01736 Scope_tab[CURRENT_SYMTAB].st_tab->Register(*Be_scope_tab[CURRENT_SYMTAB].be_st_tab);
01737
01738
01739
01740
01741 pu = PU_Info_tree_ptr(current_pu);
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752 if (!Saved_run_prompf &&
01753 Run_prompf &&
01754 Is_Set_PU_Info_flags(current_pu, PU_IS_COMPILER_GENERATED) &&
01755 !PU_mp (Get_Current_PU ())) {
01756 Saved_run_prompf = Run_prompf;
01757 Saved_run_w2c = Run_w2c;
01758 Saved_run_w2f = Run_w2f;
01759 Saved_run_w2fc_early = Run_w2fc_early;
01760 Run_prompf = FALSE;
01761 Run_w2c = FALSE;
01762 Run_w2f = FALSE;
01763 Run_w2fc_early = FALSE;
01764 }
01765
01766
01767 Orig_PU_Name = Get_Orig_PU_Name(current_pu);
01768 Save_Cur_PU_Name(ST_name(PU_Info_proc_sym(current_pu)), 0);
01769
01770 #ifdef KEY // ST_name can be deallocated later
01771 Set_Current_PU_For_Trace(Cur_PU_Name,
01772 Current_PU_Count());
01773 #else
01774 Set_Current_PU_For_Trace(ST_name(PU_Info_proc_sym(current_pu)),
01775 Current_PU_Count());
01776 #endif
01777
01778 Stop_Timer (T_ReadIR_CU);
01779 Check_for_IR_Dump(TP_IR_READ,pu,"IR_READ");
01780
01781 if (Show_Progress) {
01782 fprintf(stderr, "Compiling %s(%d)\n",
01783 ST_name(PU_Info_proc_sym(current_pu)),
01784 Current_PU_Count());
01785 }
01786
01787 if (Get_Trace(TP_REGION,TT_REGION_ALL)) {
01788 fprintf(TFile,"===== BE driver, PU loop: PU %s(%d)\n",
01789 ST_name(PU_Info_proc_sym(current_pu)),Current_PU_Count());
01790 }
01791
01792 if (Tlog_File) {
01793 fprintf(Tlog_File,"BEGIN %s\n",ST_name(PU_Info_proc_sym(current_pu)));
01794 }
01795
01796 WN_Mem_Push ();
01797
01798 if (Run_wopt || Run_cg) {
01799 Lowering_Initialize();
01800 }
01801
01802 if (Run_prompf &&
01803 !Is_Set_PU_Info_flags(current_pu, PU_IS_COMPILER_GENERATED)) {
01804 Prompf_Id_Map = Anl_Init_Map(MEM_pu_pool_ptr);
01805 WB_ANL_Initialize(pu, Prompf_Id_Map);
01806 Anl_Static_Analysis(pu, Prompf_Id_Map);
01807 WB_ANL_Terminate();
01808 }
01809
01810 if (Run_purple) {
01811 Prp_Instrument_And_EmitSrc(pu);
01812 }
01813
01814 #ifdef KEY
01815 if (Early_Goto_Conversion &&
01816
01817 (!PU_ftn_lang(Get_Current_PU()) || Early_Goto_Conversion_Set))
01818 {
01819 GTABLE goto_table( pu, MEM_pu_pool_ptr );
01820 goto_table.Remove_Gotos();
01821
01822 }
01823 #endif
01824
01825 #if defined (TARG_SL)
01826 if(Sl2_Inibuf) {
01827 if( strcmp( Cur_PU_Name, "MAIN__" ) == 0 ||
01828 strcmp( Cur_PU_Name, "main" ) == 0 ) {
01829 WN* body=WN_func_body(pu);
01830 WN* stmt=NULL;
01831 for (stmt = WN_first( body ); stmt; stmt = WN_next( stmt ) ) {
01832 if(Walk_And_Insert_Init_Buf( stmt, body ))
01833 break;
01834 }
01835
01836 FmtAssert(stmt!=NULL, ("Insert_Init_Buf failed\n"));
01837 }
01838 }
01839 #endif
01840
01841
01842 if ( Instrumentation_Enabled
01843 && (Instrumentation_Type_Num & WHIRL_PROFILE)
01844 && (Instrumentation_Phase_Num == PROFILE_PHASE_BEFORE_VHO)) {
01845 if (!is_mp_nested_pu )
01846 WN_Instrument(pu, PROFILE_PHASE_BEFORE_VHO);
01847 #if 0
01848 extern void wb_gwe(WN*);
01849 wb_gwe(pu);
01850 #endif
01851 } else if ( Feedback_Enabled[PROFILE_PHASE_BEFORE_VHO] ) {
01852 WN_Annotate(pu, PROFILE_PHASE_BEFORE_VHO, &MEM_pu_pool);
01853 }
01854
01855 #ifdef KEY
01856
01857 if ( OPT_Cyg_Instrument > 0 && ! Run_ipl &&
01858 ( ! PU_no_instrument(Get_Current_PU()) ||
01859 PU_has_inlines(Get_Current_PU()) ) ) {
01860 Set_Error_Phase ( "CYG Instrumenting" );
01861 CYG_Instrument_Driver( pu );
01862 }
01863 #endif
01864
01865 Set_Error_Phase ( "VHO Processing" );
01866 pu = VHO_Lower_Driver (current_pu, pu);
01867
01868 if ( Cur_PU_Feedback ) {
01869 Cur_PU_Feedback->Verify("after VHO lower");
01870 }
01871
01872 pu = Adjust_Opt_Level (current_pu, pu, ST_name(PU_Info_proc_sym(current_pu)));
01873
01874 if (wopt_loaded) {
01875 Create_Restricted_Map(MEM_pu_nz_pool_ptr);
01876 }
01877
01878
01879
01880
01881
01882
01883 REGION_Initialize (pu, PU_has_region (Get_Current_PU ()));
01884 return pu;
01885 }
01886
01887 static void
01888 Postprocess_PU (PU_Info *current_pu)
01889 {
01890 if (Tlog_File) {
01891 fprintf (Tlog_File, "END %s\n", ST_name(PU_Info_proc_sym(current_pu)));
01892 }
01893
01894 Current_Map_Tab = PU_Info_maptab(current_pu);
01895
01896 REGION_Finalize();
01897
01898 if (Run_wopt || Run_cg) {
01899
01900 Lowering_Finalize();
01901 }
01902
01903
01904 WN_Mem_Pop ();
01905
01906 if (wopt_loaded) {
01907 Delete_Restricted_Map();
01908 }
01909
01910 SYMTAB_IDX scope_level = PU_lexical_level(PU_Info_pu(current_pu));
01911
01912 Scope_tab[scope_level].st_tab->
01913 Un_register(*Be_scope_tab[scope_level].be_st_tab);
01914 Be_scope_tab[scope_level].be_st_tab->Clear();
01915
01916 Free_Local_Info(current_pu);
01917 MEM_POOL_Pop(MEM_pu_nz_pool_ptr);
01918 MEM_POOL_Pop(MEM_pu_pool_ptr);
01919
01920
01921
01922
01923
01924
01925
01926 if (Saved_run_prompf) {
01927 Run_prompf = Saved_run_prompf;
01928 Run_w2c = Saved_run_w2c;
01929 Run_w2f = Saved_run_w2f;
01930 Run_w2fc_early = Saved_run_w2fc_early;
01931 Saved_run_prompf = FALSE;
01932 Saved_run_w2c = FALSE;
01933 Saved_run_w2f = FALSE;
01934 Saved_run_w2fc_early = FALSE;
01935 }
01936 }
01937
01938
01939 static void
01940 Preorder_Process_PUs (PU_Info *current_pu)
01941 {
01942 INT orig_opt_level = Opt_Level;
01943 BOOL orig_run_lno = Run_lno;
01944 BOOL orig_run_preopt = Run_preopt;
01945 BOOL orig_run_wopt = Run_wopt;
01946 BOOL orig_olimit_opt = Olimit_opt;
01947
01948 WN *pu;
01949 #ifdef TARG_X8664
01950 if (!Force_Frame_Pointer_Set)
01951 {
01952 const PU & func =
01953 Pu_Table [ST_pu (St_Table [PU_Info_proc_sym (current_pu)])];
01954
01955
01956 if ((PU_cxx_lang (func) && PU_has_region (func)) || Debug_Level > 0
01957 #ifdef KEY
01958 || PU_has_goto_outer_block(func)
01959 #endif
01960 )
01961 Force_Frame_Pointer = true;
01962 else
01963 Force_Frame_Pointer = false;
01964 }
01965 #endif
01966
01967 Start_Timer(T_BE_PU_CU);
01968
01969 pu = Preprocess_PU(current_pu);
01970
01971
01972
01973
01974 Scope_tab[CURRENT_SYMTAB].preg_tab->Register(Be_preg_tab);
01975
01976 WN_verifier(pu);
01977
01978 Verify_SYMTAB (CURRENT_SYMTAB);
01979
01980 if (!PU_mp (Get_Current_PU ()) &&
01981 (Run_Dsm_Cloner || Run_Dsm_Common_Check || Run_Dsm_Check))
01982 DRA_Processing(current_pu, pu, Cur_PU_Feedback != NULL);
01983
01984
01985
01986
01987
01988 if (PU_has_mp (Get_Current_PU ()) && !FILE_INFO_ipa (File_info)) {
01989 Set_Error_Phase("OMP Pre-lowering");
01990 WB_OMP_Initialize(pu, Prompf_Id_Map);
01991 pu = OMP_Prelower(current_pu, pu);
01992 WB_OMP_Terminate();
01993 }
01994
01995 if (Run_ipl) {
01996 Ipl_Processing (current_pu, pu);
01997 Verify_SYMTAB (CURRENT_SYMTAB);
01998 }
01999 else {
02000 Backend_Processing (current_pu, pu);
02001 Verify_SYMTAB (CURRENT_SYMTAB);
02002 }
02003 if (reset_opt_level) {
02004 Opt_Level = orig_opt_level;
02005 Run_lno = orig_run_lno;
02006 Run_preopt = orig_run_preopt;
02007 Run_wopt = orig_run_wopt;
02008 reset_opt_level = FALSE;
02009 Olimit_opt = orig_olimit_opt;
02010 }
02011
02012 Scope_tab[CURRENT_SYMTAB].preg_tab->Un_register(Be_preg_tab);
02013 Be_preg_tab.Clear();
02014
02015 Stop_Timer(T_BE_PU_CU);
02016 Finish_BE_Timing ( Tim_File, ST_name(PU_Info_proc_sym(current_pu)) );
02017 Advance_Current_PU_Count();
02018
02019 Cur_PU_Name = NULL;
02020
02021
02022
02023
02024
02025
02026 Print_PU_Stats ();
02027
02028 #ifdef KEY // nested functions are no longer in the global symtab
02029 ST *st;
02030 INT i;
02031 FOREACH_SYMBOL (CURRENT_SYMTAB, st, i)
02032 if (ST_class(st) == CLASS_FUNC)
02033 Allocate_Object(st);
02034 #endif
02035
02036
02037
02038 for (PU_Info *child = PU_Info_child(current_pu);
02039 child != NULL;
02040 child = PU_Info_next(child)) {
02041 Preorder_Process_PUs(child);
02042 }
02043
02044 Postprocess_PU (current_pu);
02045 }
02046
02047 static void Print_Tlog_Header(INT argc, char **argv)
02048 {
02049 INT i;
02050 if (Get_Trace(TP_PTRACE1, TP_PTRACE1_NOHDR))
02051 return;
02052 fprintf(Tlog_File,"1.0\n");
02053 fprintf(Tlog_File,"{ ");
02054 for (i=0; i<argc; i++)
02055 fprintf(Tlog_File,"%s ", argv[i]);
02056 fprintf(Tlog_File,"}\n");
02057 }
02058
02059
02060 #define FEEDBACK_PATH_MAXLEN 1024
02061
02062
02063 static void
02064 Process_Feedback_Options (OPTION_LIST* olist)
02065 {
02066 if (Feedback_File_Name) {
02067
02068
02069
02070
02071 INT t = strlen(Feedback_File_Name);
02072 Is_True(t < FEEDBACK_PATH_MAXLEN - 16,
02073 ("Process_Feedback_Options: Feedback file name too long(%d)",
02074 t));
02075 while (t > 0 && Feedback_File_Name[t - 1] != '/')
02076 t--;
02077
02078
02079
02080
02081 char path[FEEDBACK_PATH_MAXLEN];
02082 char *prefix = Feedback_File_Name + t;
02083 if (t > 0) {
02084
02085 strncpy(path, Feedback_File_Name, t);
02086 } else {
02087
02088 path[0] = '.';
02089 path[1] = '/';
02090 t = 2;
02091 }
02092 path[t] = '\0';
02093 char *dir_end = path + t;
02094
02095 INT prefix_len = strlen(prefix);
02096 DIR* dirp = opendir(path);
02097 #ifdef KEY
02098 if (dirp == NULL)
02099 ErrMsg(EC_FB_No_File, Feedback_File_Name);
02100 #endif
02101 struct dirent* direntp;
02102 #ifdef KEY
02103 INT fb_file_count = 0;
02104 #endif
02105 while ((direntp = readdir(dirp)) != NULL) {
02106 if (strncmp(direntp->d_name, prefix, prefix_len) == 0) {
02107 strcpy(dir_end, direntp->d_name);
02108 Process_Feedback_File(path);
02109 #ifdef KEY
02110 fb_file_count++;
02111 #endif
02112 }
02113 }
02114 closedir(dirp);
02115
02116 #ifdef KEY // bug 4837
02117 if (fb_file_count == 0) {
02118 ErrMsg(EC_FB_No_File, prefix);
02119 }
02120 #endif
02121 }
02122
02123 OPTION_LIST *ol;
02124 for (ol = olist; ol != NULL; ol = OLIST_next(ol)) {
02125 char *val = OLIST_val(ol);
02126 Process_Feedback_File(val);
02127 }
02128 }
02129
02130 #ifdef TARG_SL
02131
02132 void init_ti_target(void *handle) {
02133 char *soname;
02134 if (Is_Target_Sl1_pcore()) {
02135 soname = (char*)alloca( strlen("sl1_pcore.so")+1 );
02136 strncpy( soname, "sl1_pcore.so", strlen("sl1_pcore.so")+1 );
02137 } else if (Is_Target_Sl2_pcore()) {
02138 soname = (char*)alloca( strlen("sl2_pcore.so")+1 );
02139 strncpy( soname, "sl2_pcore.so", strlen("sl2_pcore.so")+1 );
02140 } else if (Is_Target_Sl1_dsp()) {
02141 soname = (char*)alloca( strlen("sl1_dsp.so")+1 );
02142 strncpy( soname, "sl1_dsp.so", strlen("sl1_dsp.so")+1 );
02143 }else if (Target == TARGET_UNDEF) {
02144 Is_True(0, ("undefined target"));
02145 }
02146 handle = dlopen(soname, RTLD_LAZY);
02147 if (!handle) {
02148 fprintf (stderr, "Error loading %s: %s\n", soname, dlerror());
02149 exit (RC_SYSTEM_ERROR);
02150 }
02151 SI_resource_count_p = (INT *)dlsym(handle, "SI_resource_count");
02152 SI_resources_p = (SI_RESOURCE *(*)[])dlsym(handle, "SI_resources");
02153 SI_top_si_p = (SI *(*)[])dlsym(handle, "SI_top_si");
02154 SI_RRW_initializer_p = (SI_RRW *)dlsym(handle, "SI_RRW_initializer");
02155 SI_RRW_overuse_mask_p = (SI_RRW *)dlsym(handle, "SI_RRW_overuse_mask");
02156 SI_issue_slot_count_p = (INT *)dlsym(handle, "SI_issue_slot_count");
02157 SI_issue_slots_p = (SI_ISSUE_SLOT *(*)[])dlsym(handle, "SI_issue_slots");
02158 SI_ID_count_p = (INT *)dlsym(handle, "SI_ID_count");
02159 SI_ID_si_p = (SI *(*)[])dlsym(handle, "SI_ID_si");
02160 return;
02161 }
02162 #endif
02163
02164 #if defined(TARG_MIPS) && !defined(TARG_SL)
02165
02166 void init_ti_target(void *handle) {
02167 char *soname;
02168 soname = (char*)alloca( strlen("r10000.so")+1 );
02169 strncpy( soname, "r10000.so", strlen("r10000.so")+1 );
02170 handle = dlopen(soname, RTLD_LAZY);
02171 if (!handle) {
02172 fprintf (stderr, "Error loading %s: %s\n", soname, dlerror());
02173 exit (RC_SYSTEM_ERROR);
02174 }
02175 SI_resource_count_p = (INT *)dlsym(handle, "SI_resource_count");
02176 SI_resources_p = (SI_RESOURCE *(*)[])dlsym(handle, "SI_resources");
02177 SI_top_si_p = (SI *(*)[])dlsym(handle, "SI_top_si");
02178 SI_RRW_initializer_p = (SI_RRW *)dlsym(handle, "SI_RRW_initializer");
02179 SI_RRW_overuse_mask_p = (SI_RRW *)dlsym(handle, "SI_RRW_overuse_mask");
02180 SI_issue_slot_count_p = (INT *)dlsym(handle, "SI_issue_slot_count");
02181 SI_issue_slots_p = (SI_ISSUE_SLOT *(*)[])dlsym(handle, "SI_issue_slots");
02182 SI_ID_count_p = (INT *)dlsym(handle, "SI_ID_count");
02183 SI_ID_si_p = (SI *(*)[])dlsym(handle, "SI_ID_si");
02184 return;
02185 }
02186
02187 #endif
02188
02189
02190 extern "C" {
02191 void be_debug(void) {}
02192 }
02193
02194 INT
02195 main (INT argc, char **argv)
02196 {
02197 INT local_ecount, local_wcount;
02198 PU_Info *pu_tree;
02199 #if defined(TARG_SL) || defined(TARG_MIPS)
02200 void *handle;
02201 #endif
02202 #ifdef __MINGW32__
02203 setvbuf(stdout, (char *)NULL, _IOLBF, 0);
02204 setvbuf(stderr, (char *)NULL, _IOLBF, 0);
02205 #else
02206 setlinebuf (stdout);
02207 setlinebuf (stderr);
02208 #endif
02209 Handle_Signals ();
02210 MEM_Initialize ();
02211 Cur_PU_Name = NULL;
02212 Init_Error_Handler ( 100 );
02213 #if !defined(SHARED_BUILD)
02214 Set_Error_Tables ( Phases, host_errlist );
02215 #endif
02216 Set_Error_Line ( ERROR_LINE_UNKNOWN );
02217 Set_Error_File ( NULL );
02218 Set_Error_Phase ( "Back End Driver" );
02219
02220 Preconfigure ();
02221 Process_Command_Line (argc, argv);
02222 if (Inhibit_EH_opt && Opt_Level > 1) Opt_Level = 1;
02223 Reset_Timers ();
02224 Start_Timer(T_BE_Comp);
02225 Prepare_Source ();
02226 Initialize_Stats ();
02227 Configure ();
02228 Configure_Source(NULL);
02229 #ifdef Is_True_On
02230 if (Get_Trace (TKIND_ALLOC, TP_MISC)) {
02231 MEM_Tracing_Enable();
02232 }
02233 #endif
02234 if ( List_Enabled ) {
02235 Prepare_Listing_File ();
02236 List_Compile_Options ( Lst_File, "", FALSE, List_All_Options, FALSE );
02237 }
02238
02239 Init_Operator_To_Opcode_Table();
02240 #if defined(TARG_SL) || defined(TARG_MIPS)
02241 init_ti_target(handle);
02242 #endif
02243
02244 load_components (argc, argv);
02245 be_debug();
02246
02247 MEM_POOL_Push (&MEM_src_pool);
02248 MEM_POOL_Push (&MEM_src_nz_pool);
02249 if ( Show_Progress ) {
02250 fprintf ( stderr, "Compiling %s (%s) -- Back End\n",
02251 Src_File_Name, Irb_File_Name );
02252 fflush ( stderr );
02253 }
02254 Set_Error_Source (Src_File_Name);
02255
02256
02257 Options_Stack = CXX_NEW(OPTIONS_STACK(&MEM_src_nz_pool), &MEM_src_nz_pool);
02258 Options_Stack->Push_Current_Options();
02259
02260 Start_Timer (T_ReadIR_Comp);
02261 if (Read_Global_Data) {
02262
02263 Irb_File = (FILE *)Open_Global_Input (Global_File_Name);
02264 Irb_File = (FILE *)Open_Local_Input (Irb_File_Name);
02265 }
02266 else {
02267 Irb_File = (FILE *)Open_Input_Info (Irb_File_Name);
02268 }
02269 Initialize_Symbol_Tables (FALSE);
02270 New_Scope (GLOBAL_SYMTAB, Malloc_Mem_Pool, FALSE);
02271
02272 INT pu_num;
02273 pu_tree = Read_Global_Info (&pu_num);
02274
02275 #if defined(TARG_SL)
02276 if (Run_ipisr) {
02277 isr_cg = CXX_NEW_ARRAY(ISR_NODE, pu_num, &MEM_src_nz_pool);
02278 Read_isr_cg(isr_cg, pu_num);
02279 }
02280 #endif
02281
02282 Stop_Timer (T_ReadIR_Comp);
02283
02284 Initialize_Special_Global_Symbols ();
02285
02286
02287
02288 if (FILE_INFO_ipa (File_info)) {
02289 if (Instrumentation_Enabled
02290 && (Instrumentation_Type_Num & WHIRL_PROFILE)
02291 && (Instrumentation_Phase_Num <= PROFILE_PHASE_IPA_CUTOFF)) {
02292 Instrumentation_Enabled = FALSE;
02293 #ifdef KEY // bug 5684: deleting branches interferes with branch profiling
02294 WOPT_Enable_Simple_If_Conv = FALSE;
02295 #endif
02296 Instrumentation_Phase_Num = PROFILE_PHASE_NONE;
02297 }
02298 }
02299
02300 Process_Feedback_Options (Feedback_Option);
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311 if (Run_Dsm_Cloner || Run_Dsm_Common_Check) {
02312 DRA_Initialize();
02313 }
02314 BOOL needs_lno = FILE_INFO_needs_lno (File_info);
02315
02316 if (needs_lno && !Run_ipl) {
02317 Run_Distr_Array = TRUE;
02318 if (!Run_lno && !Run_autopar) {
02319
02320
02321 INT phase_argc;
02322 char **phase_argv;
02323
02324 if (!Run_wopt && !Run_preopt) {
02325
02326 Get_Phase_Args (PHASE_WOPT, &phase_argc, &phase_argv);
02327 load_so ("wopt.so", WOPT_Path, Show_Progress);
02328 wopt_main (phase_argc, phase_argv, argc, argv);
02329 wopt_loaded = TRUE;
02330 }
02331
02332 Get_Phase_Args (PHASE_LNO, &phase_argc, &phase_argv);
02333 load_so ("lno.so", LNO_Path, Show_Progress);
02334 lno_main (phase_argc, phase_argv, argc, argv);
02335 }
02336 }
02337
02338
02339
02340
02341 BE_symtab_initialize_be_scopes();
02342 BE_symtab_alloc_scope_level(GLOBAL_SYMTAB);
02343 SYMTAB_IDX scope_level;
02344 for (scope_level = 0;
02345 scope_level <= GLOBAL_SYMTAB;
02346 ++scope_level) {
02347
02348
02349 if (Scope_tab[scope_level].st_tab != NULL) {
02350 Scope_tab[scope_level].st_tab->
02351 Register(*Be_scope_tab[scope_level].be_st_tab);
02352 }
02353 else {
02354 Is_True(scope_level == 0,
02355 ("Nonexistent st_tab for level %d", scope_level));
02356 }
02357 }
02358
02359 Phase_Init ();
02360
02361 if (Run_preopt || Run_wopt || Run_lno || Run_Distr_Array || Run_autopar
02362 || Run_cg) {
02363 Set_Error_Descriptor (EP_BE, EDESC_BE);
02364 Set_Error_Descriptor (EP_CG, EDESC_CG);
02365 }
02366
02367 if (Tlog_File)
02368 Print_Tlog_Header(argc, argv);
02369
02370 if (Run_ipl)
02371 Preprocess_struct_access();
02372 #ifdef KEY
02373 if (profile_arcs && pu_tree) {
02374 Output_Func_Start_Profiler.Set_file_name(Src_File_Name);
02375 Output_Func_Start_Profiler.Set_pu_tree(&pu_tree);
02376 Output_Func_Start_Profiler.Generate_Func_Start_Profiler_PU();
02377 Output_Func_Start_Profiler.Fill_In_Func_Body();
02378 }
02379 #endif
02380
02381 #if defined(TARG_SL)
02382 if (!Run_ipisr) {
02383 for (PU_Info *current_pu = pu_tree;
02384 current_pu != NULL;
02385 current_pu = PU_Info_next(current_pu)) {
02386 Preorder_Process_PUs(current_pu);
02387 }
02388 } else {
02389 INT i = 0;
02390 for (PU_Info *current_pu = pu_tree;
02391 current_pu != NULL;
02392 current_pu = PU_Info_next(current_pu), i++)
02393 {
02394 Merge_Parents_Regset(isr_cg[i]);
02395 Preorder_Process_PUs(current_pu);
02396 }
02397 }
02398 #else
02399 for (PU_Info *current_pu = pu_tree;
02400 current_pu != NULL;
02401 current_pu = PU_Info_next(current_pu)) {
02402 Preorder_Process_PUs(current_pu);
02403 }
02404 #endif
02405
02406
02407 if (Show_Progress) {
02408 fprintf (stderr, "\n");
02409 fflush (stderr);
02410 }
02411 Phase_Fini ();
02412
02413 #ifdef KEY
02414
02415
02416 if ( List_Enabled ) {
02417 Mhd_Options.Merge_Options(Mhd);
02418 Prepare_Listing_File ();
02419 List_Compile_Options ( Lst_File, "", FALSE, List_All_Options, FALSE );
02420 }
02421 #endif
02422
02423
02424
02425 Is_True(scope_level == GLOBAL_SYMTAB + 1,
02426 ("scope_level must be GLOBAL_SYMTAB + 1, left from earlier loop"));
02427
02428 do {
02429 --scope_level;
02430
02431
02432 if (Scope_tab[scope_level].st_tab != NULL) {
02433 Scope_tab[scope_level].st_tab->
02434 Un_register(*Be_scope_tab[scope_level].be_st_tab);
02435 Be_scope_tab[scope_level].be_st_tab->Clear();
02436 }
02437 else {
02438 Is_True(scope_level == 0,
02439 ("Nonexistent st_tab for level %d", scope_level));
02440 }
02441 } while (scope_level != 0);
02442
02443 BE_symtab_free_be_scopes();
02444
02445
02446 if (need_wopt_output || need_lno_output || need_ipl_output) {
02447 Write_Global_Info (pu_tree);
02448 if (need_ipl_output)
02449 Ipl_Extra_Output (ir_output);
02450 Close_Output_Info ();
02451 }
02452 else if (Emit_Global_Data) {
02453 Write_Global_Info (NULL);
02454 Close_Output_Info ();
02455 }
02456
02457
02458 Print_Total_Stats ();
02459 if ((Opt_Level > 0 || Run_autopar)
02460 && Max_Src_Olimit > Olimit && !Olimit_opt && Show_OPT_Warnings) {
02461 ErrMsg (EC_File_Olimit_Exceeded, Max_Src_Olimit);
02462 }
02463
02464 Stop_Timer(T_BE_Comp);
02465 Finish_Compilation_Timing ( Tim_File, Src_File_Name );
02466
02467 MEM_POOL_Pop ( &MEM_src_pool );
02468 MEM_POOL_Pop ( &MEM_src_nz_pool );
02469 #ifdef Is_True_On
02470 if (Get_Trace (TKIND_ALLOC, TP_MISC)) {
02471 fprintf (TFile, "\n%s\tMemory allocation information after be\n", DBar);
02472 MEM_Trace ();
02473 }
02474 #endif
02475
02476
02477 if ( Get_Error_Count ( &local_ecount, &local_wcount ) ) {
02478 ecount += local_ecount;
02479 }
02480
02481 if ( ecount > 0 ) {
02482 Terminate(Had_Internal_Error() ? RC_INTERNAL_ERROR : RC_NORECOVER_USER_ERROR) ;
02483 }
02484
02485 if (local_wcount && warnings_are_errors) {
02486 Terminate(RC_USER_ERROR);
02487 }
02488
02489
02490 Cleanup_Files ( TRUE, FALSE );
02491 exit ( RC_OKAY );
02492
02493
02494 }