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
00057
00058
00059 #define __STDC_LIMIT_MACROS
00060 #include <stdint.h>
00061 #include <dlfcn.h>
00062
00063 #ifndef BACK_END
00064 #define BACK_END // config.h needs it
00065 #endif
00066 #include "be_symtab.h"
00067 #include "config.h"
00068 #include "dso.h"
00069 #include "erglob.h"
00070 #include "glob.h"
00071 #include "ir_reader.h"
00072 #include "ipa_cg.h"
00073 #include "ipa_option.h"
00074 #include "ipa_summary.h"
00075 #include "ipa_section_annot.h"
00076 #include "ipl_array_bread_write.h"
00077 #include "ipl_main.h"
00078 #include "ipl_driver.h"
00079 #define IPA_SUMMARY // SUMMARIZE<IPL>
00080 #include "ipl_summarize.h"
00081 #undef IPA_SUMMARY
00082 #include "ipo_const.h"
00083 #include "ipo_defs.h"
00084 #include "optimizer.h"
00085 #include "region_main.h"
00086 #include "ipa_main.h"
00087
00088
00089 #pragma weak Create_Du_Manager
00090 #pragma weak Delete_Du_Manager
00091 #pragma weak Pre_Optimizer
00092
00093
00094 #pragma weak Array_Summary_Output
00095 #pragma weak Do_Par
00096 #pragma weak Ipl_Init_From_Ipa
00097 #pragma weak Summary
00098 #pragma weak Trace__20ARRAY_SUMMARY_OUTPUTGP8__file_s
00099 #pragma weak Trace__31SUMMARIZE__pt__14_XC7PROGRAML10GP8__file_s
00100
00101
00102 class ST_IDX_PAIR_TO_INT32_HASH_TABLE
00103 {
00104 private:
00105 struct HASH_ELEMENT
00106 {
00107 ST_IDX _symbol_st_idx;
00108 ST_IDX _func_st_idx;
00109 INT32 _symbol_index;
00110 HASH_ELEMENT* _next;
00111 } *_table[0x40];
00112
00113 MEM_POOL* _mem_pool;
00114
00115 UINT32 hash(ST_IDX st_idx, ST_IDX func_st_idx) const
00116 {
00117 return ((ST_IDX_index(st_idx) | ST_IDX_index(func_st_idx)) & 0xff) >> 2;
00118 }
00119
00120 public:
00121 ST_IDX_PAIR_TO_INT32_HASH_TABLE (MEM_POOL* mem_pool) :
00122 _mem_pool (mem_pool)
00123 {
00124 bzero(_table, sizeof(_table));
00125 }
00126
00127 void Enter (ST_IDX symbol_st_idx, ST_IDX func_st_idx, INT32 symbol_index)
00128 {
00129 HASH_ELEMENT* p = CXX_NEW (HASH_ELEMENT, _mem_pool);
00130 UINT32 hash_value = hash (symbol_st_idx, func_st_idx);
00131 p->_symbol_st_idx = symbol_st_idx;
00132 p->_func_st_idx = func_st_idx;
00133 p->_symbol_index = symbol_index;
00134 p->_next = _table[hash_value];
00135 _table[hash_value] = p;
00136 }
00137
00138 INT32 Find (ST_IDX symbol_st_idx, ST_IDX func_st_idx) const
00139 {
00140 UINT32 hash_value = hash (symbol_st_idx, func_st_idx);
00141 HASH_ELEMENT* p = _table[hash_value];
00142 while (p) {
00143 if (p->_symbol_st_idx == symbol_st_idx &&
00144 p->_func_st_idx == func_st_idx) {
00145 return p->_symbol_index;
00146 }
00147 p = p->_next;
00148 }
00149 return -1;
00150 }
00151
00152 };
00153
00154
00155 struct AUX_FILE_INFO
00156 {
00157 ST_IDX_PAIR_TO_INT32_HASH_TABLE* symbol_index_map;
00158 INT32 max_symbol_size;
00159 };
00160
00161
00162 static MEM_POOL IPA_preopt_pool;
00163 static BOOL IPA_preopt_initialized = FALSE;
00164 static AUX_FILE_INFO* Aux_file_info;
00165
00166
00167
00168
00169
00170
00171 static void
00172 IPA_build_symbol_index_map (const IPA_NODE* node)
00173 {
00174 AUX_FILE_INFO& file_info = Aux_file_info[node->File_Index()];
00175
00176
00177 if (file_info.symbol_index_map == 0) {
00178
00179 file_info.symbol_index_map =
00180 CXX_NEW (ST_IDX_PAIR_TO_INT32_HASH_TABLE (&IPA_preopt_pool),
00181 &IPA_preopt_pool);
00182
00183 INT32 num_symbols;
00184 SUMMARY_SYMBOL* symbols =
00185 IPA_get_symbol_file_array(node->File_Header(), num_symbols);
00186
00187
00188
00189 for (INT32 i = 0; i < num_symbols; ++i) {
00190 ST_IDX symbol_st_idx = symbols[i].St_idx();
00191 ST_IDX func_st_idx = (ST_IDX_level(symbol_st_idx) == GLOBAL_SYMTAB) ?
00192 0 : symbols[i].Get_st_idx_func();
00193 file_info.symbol_index_map->Enter (symbol_st_idx, func_st_idx, i);
00194 }
00195 }
00196 }
00197
00198
00199
00200
00201
00202
00203 static INT32
00204 IPA_add_new_symbol (const IPA_NODE* node,
00205 const SUMMARY_SYMBOL& symbol)
00206 {
00207 AUX_FILE_INFO& file_info = Aux_file_info[node->File_Index()];
00208 IP_FILE_HDR& file_hdr = node->File_Header();
00209 SUMMARY_FILE_HEADER* summary_header = IP_FILE_HDR_file_header (file_hdr);
00210
00211 INT32 num_syms;
00212 SUMMARY_SYMBOL* old_symbols = IPA_get_symbol_file_array (file_hdr, num_syms);
00213 SUMMARY_SYMBOL* new_symbols;
00214 INT32 num_bytes = num_syms * sizeof(SUMMARY_SYMBOL);
00215
00216
00217 if (file_info.max_symbol_size == 0) {
00218 file_info.max_symbol_size = num_syms * 2;
00219 new_symbols = (SUMMARY_SYMBOL*)
00220 MEM_POOL_Alloc (Malloc_Mem_Pool, num_bytes * 2);
00221 memcpy (new_symbols, old_symbols, num_bytes);
00222 Elf64_Word new_offset = summary_header->Get_symbol_offset() +
00223 ((char*) new_symbols - (char*) old_symbols);
00224 summary_header->Set_symbol_offset (new_offset);
00225 }
00226
00227 else if (file_info.max_symbol_size <= num_syms) {
00228 file_info.max_symbol_size = num_syms * 2;
00229 new_symbols = (SUMMARY_SYMBOL*)
00230 MEM_POOL_Realloc (Malloc_Mem_Pool, old_symbols, num_bytes, num_bytes*2);
00231 Elf64_Word new_offset = summary_header->Get_symbol_offset() +
00232 ((char*) new_symbols - (char*) old_symbols);
00233 summary_header->Set_symbol_offset (new_offset);
00234 }
00235 else {
00236 new_symbols = old_symbols;
00237 }
00238
00239 new_symbols[num_syms] = symbol;
00240 summary_header->Set_symbol_size(num_syms + 1);
00241
00242 return num_syms;
00243 }
00244
00245
00246
00247
00248
00249
00250 static INT32
00251 IPA_map_symbol_index (const IPA_NODE* node,
00252 const SUMMARY_SYMBOL& symbol)
00253 {
00254 AUX_FILE_INFO& file_info = Aux_file_info[node->File_Index()];
00255 Is_True (file_info.symbol_index_map,
00256 ("Hash table for symbol to index mapping is not initialized"));
00257
00258 ST_IDX symbol_st_idx = symbol.St_idx();
00259 ST_IDX func_st_idx = (ST_IDX_level(symbol_st_idx) == GLOBAL_SYMTAB) ?
00260 0 : symbol.Get_st_idx_func();
00261
00262
00263
00264 INT32 sym_idx = file_info.symbol_index_map->Find(symbol_st_idx, func_st_idx);
00265 if (sym_idx == -1) {
00266 sym_idx = IPA_add_new_symbol (node, symbol);
00267 file_info.symbol_index_map->Enter (symbol_st_idx, func_st_idx, sym_idx);
00268 }
00269
00270 return sym_idx;
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280 static void
00281 IPA_update_formal_symbol_indices (const IPA_NODE* node,
00282 SUMMARY* new_summary)
00283 {
00284 SUMMARY_FORMAL* old_formals = IPA_get_formal_array(node) +
00285 node->Summary_Proc()->Get_formal_index();
00286
00287 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00288 SUMMARY_FORMAL* new_formals = new_summary->Get_formal(0);
00289 UINT num_formals = node->Num_Formals();
00290
00291 for (UINT i = 0; i < num_formals; ++i) {
00292 INT32 new_sym_idx = new_formals[i].Get_symbol_index();
00293 if (new_sym_idx != -1) {
00294 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00295 new_formals[i].Set_symbol_index (old_sym_idx);
00296 IPA_get_symbol_array(node)[old_sym_idx].Set_findex(i);
00297 }
00298 }
00299 }
00300
00301
00302
00303
00304
00305
00306 static void
00307 IPA_update_actual_symbol_indices (const IPA_NODE* node,
00308 SUMMARY* new_summary)
00309 {
00310 SUMMARY_FORMAL* old_formals = IPA_get_formal_array(node) +
00311 node->Summary_Proc()->Get_formal_index();
00312
00313 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00314 SUMMARY_ACTUAL* new_actuals = new_summary->Get_actual(0);
00315 INT32 num_new_actuals = new_summary->Get_actual_idx() + 1;
00316
00317 for (INT32 i = 0; i < num_new_actuals; ++i) {
00318 INT32 new_sym_idx = new_actuals[i].Get_symbol_index();
00319 if (new_sym_idx != -1) {
00320 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00321 new_actuals[i].Set_symbol_index (old_sym_idx);
00322 }
00323 }
00324 }
00325
00326
00327
00328
00329
00330
00331 static void
00332 IPA_update_global_symbol_indices (const IPA_NODE* node,
00333 SUMMARY* new_summary)
00334 {
00335 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00336 SUMMARY_GLOBAL* new_globals = new_summary->Get_global(0);
00337 INT32 num_new_globals = new_summary->Get_global_idx() + 1;
00338
00339 for (INT32 i = 0; i < num_new_globals; ++i) {
00340 INT32 new_sym_idx = new_globals[i].Get_symbol_index();
00341 Is_True (new_sym_idx != -1, ("Invalid symbol index in SUMMARY_GLOBAL"));
00342 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00343 new_globals[i].Set_symbol_index (old_sym_idx);
00344 }
00345 }
00346
00347
00348
00349
00350
00351
00352 static void
00353 IPA_update_callsite_symbol_indices (const IPA_NODE* node,
00354 SUMMARY* new_summary)
00355 {
00356 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00357 SUMMARY_CALLSITE* new_callsites = new_summary->Get_callsite(0);
00358 INT32 num_new_callsites = new_summary->Get_callsite_idx() + 1;
00359
00360 for (INT32 i = 0; i < num_new_callsites; ++i) {
00361 if (!new_callsites[i].Is_func_ptr()) {
00362 INT32 new_sym_idx = new_callsites[i].Get_symbol_index();
00363 Is_True(new_sym_idx != -1, ("Invalid symbol index in SUMMARY_CALLSITE"));
00364 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00365 new_callsites[i].Set_symbol_index (old_sym_idx);
00366 }
00367 }
00368 }
00369
00370
00371
00372
00373
00374
00375 static void
00376 IPA_update_stid_symbol_indices (const IPA_NODE* node,
00377 SUMMARY* new_summary)
00378 {
00379 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00380 SUMMARY_STID* new_stids = new_summary->Get_global_stid(0);
00381 INT32 num_new_stids = new_summary->Get_global_stid_idx() + 1;
00382
00383 for (INT32 i = 0; i < num_new_stids; ++i) {
00384 INT32 new_sym_idx = new_stids[i].Get_symbol_index();
00385 Is_True (new_sym_idx != -1, ("Invalid symbol index in SUMMARY_STID"));
00386 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00387 new_stids[i].Set_symbol_index (old_sym_idx);
00388 }
00389 }
00390
00391
00392
00393
00394
00395
00396 static void
00397 IPA_update_value_symbol_indices (const IPA_NODE* node,
00398 SUMMARY* new_summary)
00399 {
00400 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00401 SUMMARY_VALUE* new_values = new_summary->Get_value(0);
00402 INT32 num_new_values = new_summary->Get_value_idx() + 1;
00403
00404 for (INT32 i = 0; i < num_new_values; ++i) {
00405 if (new_values[i].Is_global()) {
00406 INT32 new_sym_idx = new_values[i].Get_global_index();
00407 if (new_sym_idx != -1) {
00408 INT32 old_sym_idx=IPA_map_symbol_index(node,new_symbols[new_sym_idx]);
00409 new_values[i].Set_global_index (old_sym_idx);
00410 }
00411 }
00412 else if (new_values[i].Is_symbol()) {
00413 INT32 new_sym_idx = new_values[i].Get_symbol_index();
00414 Is_True (new_sym_idx != -1, ("Invalid symbol index in SUMMARY_VALUE"));
00415 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00416 new_values[i].Set_symbol_index (old_sym_idx);
00417 }
00418 }
00419 }
00420
00421
00422
00423
00424
00425
00426 static void
00427 IPA_update_chi_symbol_indices (const IPA_NODE* node,
00428 SUMMARY* new_summary)
00429 {
00430 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00431 SUMMARY_CHI* new_chis = new_summary->Get_chi(0);
00432 INT32 num_new_chis = new_summary->Get_chi_idx() + 1;
00433
00434 for (INT32 i = 0; i < num_new_chis; ++i) {
00435 INT32 new_sym_idx = new_chis[i].Get_symbol_index();
00436 Is_True (new_sym_idx != -1, ("Invalid symbol index in SUMMARY_CHI"));
00437 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00438 new_chis[i].Set_symbol_index (old_sym_idx);
00439 }
00440 }
00441
00442
00443
00444
00445
00446
00447 static void
00448 IPA_update_region_symbol_indices (const IPA_NODE* node,
00449 SUMMARY* new_summary,
00450 ARRAY_SUMMARY_OUTPUT* new_array_summary)
00451 {
00452 SUMMARY_FORMAL* old_formals = IPA_get_formal_array(node) +
00453 node->Summary_Proc()->Get_formal_index();
00454
00455 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00456 REGION_ARRAYS* new_regions = new_array_summary->Get_region_array(0);
00457 INT32 num_new_regions = new_array_summary->Get_region_count() + 1;
00458
00459 for (INT32 i = 0; i < num_new_regions; ++i) {
00460 INT32 new_sym_idx = new_regions[i].Get_sym_id();
00461 Is_True (new_sym_idx != -1, ("Invalid symbol index in REGION_ARRAYS"));
00462 INT32 old_sym_idx = IPA_map_symbol_index (node, new_symbols[new_sym_idx]);
00463 new_regions[i].Set_sym_id (old_sym_idx);
00464 }
00465 }
00466
00467
00468
00469
00470
00471
00472 static void
00473 IPA_update_scalar_symbol_indices (const IPA_NODE* node,
00474 SUMMARY* new_summary,
00475 ARRAY_SUMMARY_OUTPUT* new_array_summary)
00476 {
00477 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00478 SCALAR_INFO* new_scalars = new_array_summary->Get_scalars(0);
00479 INT32 num_new_scalars = new_array_summary->Get_scalars_count() + 1;
00480
00481 for (INT32 i = 0; i < num_new_scalars; ++i) {
00482 INT32 new_sym_idx = new_scalars[i].Get_id();
00483 Is_True (new_sym_idx != -1, ("Invalid symbol index in SCALAR_INFO"));
00484 INT32 old_sym_idx = IPA_map_symbol_index (node, new_symbols[new_sym_idx]);
00485 new_scalars[i].Set_id (old_sym_idx);
00486 }
00487 }
00488
00489
00490
00491
00492
00493
00494 static void
00495 IPA_update_terms (const IPA_NODE* node,
00496 ARRAY_SUMMARY_OUTPUT* new_array_summary,
00497 SECTION_FILE_ANNOT* section_file_annot)
00498 {
00499 IVAR* new_ivars = new_array_summary->Get_ivar(0);
00500 TERM* new_terms = new_array_summary->Get_term(0);
00501 INT32 num_new_terms = new_array_summary->Get_term_count() + 1;
00502
00503 for (INT32 i = 0; i < num_new_terms; ++i) {
00504 if (new_terms[i].Get_type() == LTKIND_IV) {
00505 const IVAR& ivar = new_ivars[new_terms[i].Get_desc()];
00506 INT ivar_idx = section_file_annot->Find_ivar(node, ivar);
00507 if (ivar_idx == -1) {
00508 ivar_idx = section_file_annot->Add_ivar(node, ivar);
00509 }
00510 new_terms[i].Set_desc(ivar_idx);
00511 }
00512 }
00513 }
00514
00515
00516
00517
00518
00519
00520 static void
00521 IPA_update_procedure (IPA_NODE* node,
00522 SUMMARY* new_summary)
00523 {
00524
00525 SUMMARY_SYMBOL* new_symbols = new_summary->Get_symbol(0);
00526 SUMMARY_PROCEDURE* new_proc = new_summary->Get_procedure(0);
00527 INT32 new_sym_idx = new_proc->Get_symbol_index();
00528 Is_True (new_sym_idx != -1, ("Invalid symbol index in SUMMARY_PROCEDURE"));
00529 INT32 old_sym_idx = IPA_map_symbol_index(node, new_symbols[new_sym_idx]);
00530 new_proc->Set_symbol_index (old_sym_idx);
00531
00532 #ifdef KEY
00533 new_proc->Set_size (PU_WN_BB_Cnt, PU_WN_Stmt_Cnt, new_proc->Get_call_count());
00534 #endif
00535
00536
00537 *(node->Summary_Proc()) = *new_proc;
00538 }
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548 static void
00549 IPA_preopt_initialize ()
00550 {
00551 load_so ("wopt.so", WOPT_Path, Show_Progress);
00552 load_so ("ipl.so", Ipl_Path, Show_Progress);
00553
00554 MEM_POOL_Initialize (&IPA_preopt_pool, "IPA preopt pool", FALSE);
00555 MEM_POOL_Push (&IPA_preopt_pool);
00556
00557 UINT32 bytes = IP_File_header.size() * sizeof(AUX_FILE_INFO);
00558 Aux_file_info = (AUX_FILE_INFO*) MEM_POOL_Alloc (&IPA_preopt_pool, bytes);
00559 bzero (Aux_file_info, bytes);
00560 }
00561
00562
00563
00564
00565
00566
00567
00568 void
00569 IPA_Preopt_Finalize ()
00570 {
00571 if (IPA_preopt_initialized) {
00572
00573
00574
00575 Eliminate_Dead_Func(FALSE);
00576
00577 MEM_POOL_Pop (&IPA_preopt_pool);
00578 MEM_POOL_Delete (&IPA_preopt_pool);
00579
00580 IPA_preopt_initialized = FALSE;
00581 }
00582 }
00583
00584 #ifdef KEY
00585
00586
00587
00588 static void
00589 Compute_PU_Size (WN * wn)
00590 {
00591 if (!wn) return;
00592
00593 WN * wn2;
00594
00595 switch (WN_operator(wn)) {
00596
00597 case OPR_BLOCK:
00598 wn2 = WN_first(wn);
00599 while (wn2) {
00600 Compute_PU_Size(wn2);
00601 wn2 = WN_next(wn2);
00602 }
00603 break;
00604
00605 case OPR_REGION:
00606 Compute_PU_Size(WN_region_body(wn));
00607 break;
00608
00609 case OPR_IF:
00610 Compute_PU_Size(WN_if_test(wn));
00611 if (WN_then(wn))
00612 Compute_PU_Size(WN_then(wn));
00613 if (WN_else(wn))
00614 Compute_PU_Size(WN_else(wn));
00615 break;
00616
00617 case OPR_DO_LOOP:
00618 Compute_PU_Size(WN_start(wn));
00619 Compute_PU_Size(WN_step(wn));
00620 Compute_PU_Size(WN_end(wn));
00621 Compute_PU_Size(WN_do_body(wn));
00622 break;
00623
00624 case OPR_WHILE_DO:
00625 case OPR_DO_WHILE:
00626 Compute_PU_Size(WN_while_test(wn));
00627 Compute_PU_Size(WN_while_body(wn));
00628 break;
00629
00630 case OPR_SWITCH:
00631 case OPR_COMPGOTO:
00632 case OPR_XGOTO:
00633 {
00634 WN *targ_blk = WN_kid1(wn);
00635 wn2 = WN_first(targ_blk);
00636 INT t = WN_num_entries(wn) - 1;
00637 for ( ; t >= 0; --t, wn2 = WN_next(wn2) )
00638 Compute_PU_Size(wn2);
00639 break;
00640 }
00641
00642 default:
00643 {
00644 INT i;
00645 for (i = 0; i < WN_kid_count(wn); i++) {
00646 wn2 = WN_kid(wn,i);
00647 if (wn2)
00648 Compute_PU_Size(wn2);
00649 }
00650 }
00651 }
00652 Count_WN_Operator (WN_operator (wn), WN_rtype (wn) , PU_WN_BB_Cnt, PU_WN_Stmt_Cnt, PU_WN_Call_Cnt);
00653 }
00654 #endif // KEY
00655
00656
00657
00658
00659
00660 void
00661 IPA_Preoptimize (IPA_NODE* node)
00662 {
00663 Is_True (!node->Is_Quasi_Clone(), ("Quasi-clones cannot be preoptimized!"));
00664
00665
00666
00667 if (node->Is_Nested_PU() || node->Summary_Proc()->Is_alt_entry()) {
00668 return;
00669 }
00670
00671
00672 if (!IPA_preopt_initialized) {
00673 IPA_preopt_initialize();
00674 IPA_preopt_initialized = TRUE;
00675 }
00676
00677 IPA_NODE_CONTEXT context(node);
00678
00679
00680 IPO_propagate_globals (node);
00681 IPA_Propagate_Constants (node, FALSE);
00682
00683 WN* wn = node->Whirl_Tree();
00684
00685 if (Get_Trace(TP_IPA, IPA_TRACE_PREOPT_IPL)) {
00686 fprintf (TFile, "\n%s before preopt\n", node->Name());
00687 fdump_tree (TFile, wn);
00688 }
00689
00690
00691 REGION_Initialize (wn, PU_has_region(node->Get_PU()));
00692
00693 MEM_POOL_Push (&MEM_local_pool);
00694
00695 Set_Error_Phase ("IPA Global Optimizer");
00696
00697 Ipl_Init_From_Ipa (Malloc_Mem_Pool);
00698
00699 IPL_SUMMARY_PTRS* summary_ptrs =
00700 CXX_NEW (IPL_SUMMARY_PTRS (Summary, Array_Summary_Output),
00701 Malloc_Mem_Pool);
00702
00703
00704 Run_preopt = TRUE;
00705 Run_ipl = TRUE;
00706 #ifndef KEY
00707 Do_Par = TRUE;
00708 #endif
00709
00710 BE_symtab_alloc_scope_level(CURRENT_SYMTAB);
00711 Scope_tab[CURRENT_SYMTAB].st_tab->
00712 Register(*Be_scope_tab[CURRENT_SYMTAB].be_st_tab);
00713 Scope_tab[CURRENT_SYMTAB].preg_tab->Register(Be_preg_tab);
00714
00715 PU_adjust_addr_flags(Get_Current_PU_ST(), wn);
00716
00717 DU_MANAGER* du_mgr = Create_Du_Manager (MEM_pu_nz_pool_ptr);
00718 ALIAS_MANAGER* alias_mgr = Create_Alias_Manager (MEM_pu_nz_pool_ptr);
00719
00720
00721 WN* opt_wn = Pre_Optimizer (PREOPT_IPA1_PHASE, wn, du_mgr, alias_mgr);
00722
00723 Delete_Du_Manager (du_mgr, MEM_pu_nz_pool_ptr);
00724 Delete_Alias_Manager (alias_mgr, MEM_pu_nz_pool_ptr);
00725
00726 Scope_tab[CURRENT_SYMTAB].preg_tab->Un_register(Be_preg_tab);
00727 Be_preg_tab.Clear();
00728 Scope_tab[CURRENT_SYMTAB].st_tab->
00729 Un_register(*Be_scope_tab[CURRENT_SYMTAB].be_st_tab);
00730 Be_scope_tab[CURRENT_SYMTAB].be_st_tab->Clear();
00731
00732 REGION_Finalize();
00733
00734 #ifdef KEY
00735
00736 PU_WN_BB_Cnt = PU_WN_Stmt_Cnt = PU_WN_Call_Cnt = 0;
00737 Compute_PU_Size (opt_wn);
00738 #endif
00739
00740 if (Get_Trace(TP_IPA, IPA_TRACE_PREOPT_IPL)) {
00741 fprintf (TFile, "\n%s after preopt\n", node->Name());
00742 fdump_tree (TFile, opt_wn);
00743 Summary->Trace (TFile);
00744 Array_Summary_Output->Trace (TFile);
00745 }
00746
00747 #if Is_True_On
00748 WN_verifier(opt_wn);
00749 #endif
00750
00751 if (Summary->Has_symbol_entry()) {
00752 IPA_build_symbol_index_map (node);
00753 }
00754
00755 if (Summary->Has_formal_entry()) {
00756 IPA_update_formal_symbol_indices (node, Summary);
00757 }
00758 if (Summary->Has_actual_entry()) {
00759 IPA_update_actual_symbol_indices (node, Summary);
00760 }
00761 if (Summary->Has_global_entry()) {
00762 IPA_update_global_symbol_indices (node, Summary);
00763 }
00764 if (Summary->Has_callsite_entry()) {
00765 IPA_update_callsite_symbol_indices (node, Summary);
00766 }
00767
00768 #define _IPA_ITERATE_PREOPT_
00769 #ifdef _IPA_ITERATE_PREOPT_
00770 if (Summary->Has_global_stid_entry()) {
00771 IPA_update_stid_symbol_indices (node, Summary);
00772 }
00773 if (Summary->Has_value_entry()) {
00774 IPA_update_value_symbol_indices (node, Summary);
00775 }
00776 if (Summary->Has_chi_entry()) {
00777 IPA_update_chi_symbol_indices (node, Summary);
00778 }
00779 #endif // _IPA_ITERATE_PREOPT_
00780
00781 SECTION_FILE_ANNOT* section_annot =
00782 IP_FILE_HDR_section_annot(node->File_Header());
00783 if (section_annot && Array_Summary_Output->Get_term_count() != -1) {
00784 IPA_update_terms (node, Array_Summary_Output, section_annot);
00785 }
00786 if (Array_Summary_Output->Get_region_count() != -1) {
00787 IPA_update_region_symbol_indices (node, Summary, Array_Summary_Output);
00788 }
00789 if (Array_Summary_Output->Get_scalars_count() != -1) {
00790 IPA_update_scalar_symbol_indices (node, Summary, Array_Summary_Output);
00791 }
00792
00793 IPA_update_procedure (node, Summary);
00794
00795
00796 IPA_Call_Graph->Update_Node_After_Preopt (node,
00797 opt_wn,
00798 Summary->Has_callsite_entry() ?
00799 Summary->Get_callsite(0) : NULL,
00800 summary_ptrs);
00801
00802 MEM_POOL_Pop (&MEM_local_pool);
00803 }