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 #define __STDC_LIMIT_MACROS
00054 #include <stdint.h>
00055 #if defined(BUILD_OS_DARWIN)
00056 #include <darwin_elf.h>
00057 #else
00058 #include <elf.h>
00059 #endif
00060
00061 #include "defs.h"
00062 #include "strtab.h"
00063 #include "ipl_summary.h"
00064 #include "ipc_symtab_merge.h"
00065 #include "ipl_tlog.h"
00066
00067
00068 SUMMARY_SYMBOL *Ipl_Summary_Symbol;
00069 const INT MODREF_MAX_STRING_LENGTH = 1000;
00070 char Modref_Buf[MODREF_MAX_STRING_LENGTH];
00071 BOOL IPA_Trace_Mod_Ref = FALSE;
00072
00073
00074
00075 void
00076 SUMMARY_PROCEDURE::Print (FILE *fp, INT32 id) const
00077 {
00078 fprintf (fp, "PROCEDURE[%d] bb_count=%d, stmt_count=%d, %d formals (%d),"
00079 " state=0x%x", id, Get_bb_count(), Get_stmt_count(),
00080 Get_formal_count(), Get_formal_index (), Get_state() );
00081
00082 if ( Is_may_inline() )
00083 fputs (", may inline", fp);
00084
00085 if ( Is_must_inline() )
00086 fputs (", must inline", fp);
00087
00088 if ( Is_no_inline() )
00089 fputs (", no inline", fp);
00090
00091 if ( Is_varargs() )
00092 fputs (", varargs", fp);
00093
00094 if ( Is_alt_entry() )
00095 fputs (", alternate entry", fp);
00096
00097 if ( Has_alt_entry() )
00098 fprintf ( fp, ", has %d alternate entries", Get_altentry_count() );
00099
00100 if ( Has_pstatic() )
00101 fputs (", has local statics", fp);
00102
00103 if (Is_direct_mod_ref() )
00104 fputs (", has direct mods and refs", fp);
00105
00106 if (Is_exc_inline() )
00107 fputs (", has exceptions", fp);
00108
00109 if (Is_no_delete() )
00110 fputs (", no delete", fp);
00111
00112 if (Is_block_data() )
00113 fputs (", block data", fp);
00114
00115 if (Has_addr_taken_reset() )
00116 fputs (", addr_taken reset", fp);
00117
00118 if (Has_PU_freq() )
00119 fputs (", PU freq reset", fp);
00120
00121 if (Has_formal_pragma() )
00122 fputs (", formal pragma", fp);
00123
00124 if (Has_parallel_pragma() )
00125 fputs (", parallel pragma", fp);
00126
00127 if (Has_parallel_region_pragma() )
00128 fputs (", parallel region pragma", fp);
00129
00130 if (Has_fstatic() )
00131 fputs (", fstatic", fp);
00132
00133 if (Has_unknown_calls() )
00134 fputs (", unknown calls", fp);
00135
00136 if (Has_incomplete_array_info () )
00137 fputs (", incomplete array info", fp);
00138
00139 if (Has_mp_needs_lno() )
00140 fputs (", mp needs lno", fp);
00141
00142 #ifdef KEY
00143 if (Has_pragma_side_effect() )
00144 #else
00145 if (Has_side_effect() )
00146 #endif
00147 fputs (", has side effect pragmas", fp);
00148
00149 if (Has_messy_regions() )
00150 fputs (", has messy array regions", fp);
00151
00152 if (Has_unstructured_cflow())
00153 fputs (", has unstructured cflow \n", fp);
00154
00155 fprintf ( fp, "\n\t\t%d globals (%d), %d callsites (%d), %d ctrl-dep (%d), %d array-cfg(%d)",
00156 Get_global_count(), Get_global_index(), Get_callsite_count(),
00157 Get_callsite_index(), Get_ctrl_dep_count (),
00158 Get_ctrl_dep_index (), Get_array_section_count(), Get_array_section_index());
00159
00160 fprintf ( fp, "\n\t\t%d common_count (%d) feedback (%d)\n\t\t",
00161 Get_common_count(), Get_common_index(), Get_feedback_index());
00162
00163 fprintf(fp, "VALUE[%d:%d] EXPR[%d:%d]\n\t\t", Get_ex_value_index(),
00164 Get_ex_value_count(), Get_ex_expr_index(), Get_ex_expr_count());
00165
00166 if ( Ipl_Summary_Symbol ) {
00167 Ipl_Summary_Symbol[Get_symbol_index()].Print (fp);
00168 }
00169 }
00170
00171
00172 void
00173 SUMMARY_PROCEDURE::Trace ( INT32 id ) const
00174 {
00175 Print ( TFile, id );
00176 }
00177
00178 void
00179 SUMMARY_PROCEDURE::Print_array (FILE* fp, INT32 size ) const
00180 {
00181 INT i;
00182
00183 fprintf ( fp, "%sStart procedure array\n%s", SBar, SBar );
00184 for ( i=0; i<size; ++i )
00185 this[i].Print ( fp, i );
00186 fprintf ( fp, "%sEnd procedure array\n%s", SBar, SBar );
00187 }
00188
00189
00190 void
00191 SUMMARY_PROCEDURE::Trace_array ( INT32 size ) const
00192 {
00193 Print_array ( TFile, size );
00194 }
00195
00196
00197
00198 void
00199 SUMMARY_FEEDBACK::Print (FILE *f) const
00200 {
00201 fprintf (f, "cycle = ");
00202 Get_cycle_count().Print(f);
00203 fprintf (f, ", freq. = ");
00204 Get_frequency_count().Print(f);
00205 fprintf (f, ", bb_count = %d, stmt_count = %d\n",
00206 Get_effective_bb_count (), Get_effective_stmt_count ());
00207 }
00208
00209
00210 void
00211 SUMMARY_FEEDBACK::Print_array (FILE *f, INT32 size) const
00212 {
00213 fprintf (f, "%sStart feedback array\n%s", SBar, SBar);
00214 for (INT i = 0; i < size; i++) {
00215 fprintf (f, "FEEDBACK[%d]: ", i);
00216 this[i].Print (f);
00217 }
00218 fprintf (f, "%sEnd feedback array\n%s", SBar, SBar );
00219
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 void
00231 SUMMARY_CALLSITE::Print (FILE* f) const
00232 {
00233 fprintf (f, "%d actuals (@%d), map_id = %d%s",
00234 Get_param_count(), Get_actual_index(),
00235 Get_map_id(), Is_func_ptr() ? ", FPTR" : "" );
00236
00237 if (Is_must_inline())
00238 fputs ("pragma inline \n", f);
00239 if (Is_no_inline())
00240 fputs ("pragma no inline \n", f);
00241 if (Is_intrinsic ()) {
00242 fputs (", intrinsic\n", f);
00243 } else if (Is_func_ptr ())
00244 fprintf (f, ": VALUE[%d]\n", Get_value_index ());
00245 else {
00246 fputs (": ", f);
00247 Ipl_Summary_Symbol[Get_symbol_index()].Print (f);
00248 }
00249 }
00250
00251
00252
00253 void
00254 SUMMARY_CALLSITE::Trace () const
00255 {
00256 Print ( TFile );
00257 }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 void
00269 SUMMARY_CALLSITE::Print_array (FILE* f, INT32 size) const
00270 {
00271 INT i;
00272
00273 fprintf ( f, "%sStart callsite array\n%s", SBar, SBar );
00274 for ( i=0; i<size; ++i ) {
00275 fprintf ( f, "callsite[%d] : ", i );
00276 this[i].Print ( f );
00277 }
00278 fprintf ( f, "%sEnd callsite array\n%s", SBar, SBar );
00279 }
00280
00281
00282
00283 void
00284 SUMMARY_CALLSITE::Trace_array ( INT32 size ) const
00285 {
00286 Print_array ( TFile, size );
00287 }
00288
00289
00290
00291
00292
00293
00294
00295 void
00296 SUMMARY_FORMAL::Print ( FILE* fp ) const
00297 {
00298 fprintf ( fp, "pos [%d]: ", Get_position() );
00299 fprintf ( fp, "REGION[%d] ", Get_region_index());
00300 fprintf ( fp, "MTYPE(%s) ", MTYPE_name(Get_machine_type()));
00301 fprintf ( fp, "ty_idx = 0x%x ", Get_ty());
00302 if (Is_ref_parm ())
00303 fputs ("by_reference ", fp);
00304 if (Is_var_dim_array ())
00305 fputs ("var_dim_array ", fp);
00306 Ipl_Summary_Symbol[Get_symbol_index()].Print (fp);
00307 }
00308
00309
00310
00311 void
00312 SUMMARY_FORMAL::Trace ( void ) const
00313 {
00314 Print ( TFile );
00315 }
00316
00317
00318
00319 void
00320 SUMMARY_FORMAL::Print_array (FILE* fp, INT32 size) const
00321 {
00322 INT i;
00323
00324 fprintf ( fp, "%sStart formal array\n%s", SBar, SBar );
00325 for ( i=0; i<size; ++i ) {
00326 fprintf ( fp, "FORMAL[%d]: ", i );
00327 this[i].Print ( fp );
00328 }
00329 fprintf ( fp, "%sEnd formal array\n%s", SBar, SBar );
00330 }
00331
00332
00333
00334 void
00335 SUMMARY_FORMAL::Trace_array ( INT32 size ) const
00336 {
00337 Print_array ( TFile, size );
00338 }
00339
00340
00341 const char *
00342 SUMMARY_ACTUAL::Pass_type_name (void) const
00343 {
00344 switch (Get_pass_type()) {
00345 case PASS_UNKNOWN:
00346 return "PASS_UNKNOWN";
00347 case PASS_LDID:
00348 return "PASS_LDID";
00349 case PASS_LOAD:
00350 return "PASS_LOAD";
00351 case PASS_MLOAD:
00352 return "PASS_MLOAD";
00353 case PASS_LDA:
00354 return "PASS_LDA";
00355 case PASS_ARRAY_SECTION:
00356 return "PASS_ARRAY_SECTION";
00357 }
00358 return 0;
00359 }
00360
00361
00362 void
00363 SUMMARY_ACTUAL::Print (FILE *f, INT32 id) const
00364 {
00365 fprintf (f, "ACTUAL[%d]: ", id);
00366 if (Get_symbol_index () != -1)
00367 Ipl_Summary_Symbol[Get_symbol_index()].Print (f);
00368
00369 if (Is_value_parm())
00370 fprintf (f, " value_parm, ");
00371
00372 fprintf (f, " ty_idx = 0x%x, ", Get_ty());
00373
00374 const char *p = Pass_type_name ();
00375 if (p)
00376 fprintf (f, " %s, ", p);
00377 else
00378 fprintf (f, " PASS_%d, ", Get_pass_type());
00379 if (Get_pass_type() == PASS_ARRAY_SECTION)
00380 fprintf (f, " Section Idx = %d", Get_index());
00381 else
00382 fprintf (f, " Scalar Idx = %d", Get_index());
00383 fprintf (f, " Value Idx = %d \n", Get_value_index ());
00384
00385 }
00386
00387 void
00388 SUMMARY_ACTUAL::Print_array (FILE *f, INT32 size) const
00389 {
00390 fprintf (f, "%sStart actual array\n%s", SBar, SBar);
00391 for (INT i = 0; i < size; i++)
00392 this[i].Print (f, i);
00393 fprintf (f, "%sEnd actual array\n%s", SBar, SBar );
00394
00395 }
00396
00397
00398
00399 const char *
00400 SUMMARY_VALUE::Const_type_name (void) const
00401 {
00402 switch (Get_const_type()) {
00403 case VALUE_UNKNOWN:
00404 return "VALUE_UNKNOWN";
00405 case VALUE_INT_CONST:
00406 return "VALUE_INT_CONST";
00407 case VALUE_TWO_CONSTS:
00408 return "VALUE_TWO_CONSTS";
00409 case VALUE_CONST:
00410 return "VALUE_CONST";
00411 case VALUE_FORMAL:
00412 return "VALUE_FORMAL";
00413 case VALUE_GLOBAL:
00414 return "VALUE_GLOBAL";
00415 case VALUE_SYMBOL:
00416 return "VALUE_SYMBOL";
00417 case VALUE_EXPR:
00418 return "VALUE_EXPR";
00419 case VALUE_PHI:
00420 return "VALUE_PHI";
00421 case VALUE_CHI:
00422 return "VALUE_CHI";
00423 case VALUE_NOT_CONST:
00424 return "VALUE_NOT_CONST";
00425 }
00426 return 0;
00427 }
00428
00429
00430 void
00431 SUMMARY_VALUE::Print_const_value (FILE *f, const SUMMARY_SYMBOL* symbol) const
00432 {
00433 if (Is_addr_of ()) {
00434 if (!Is_convertible_to_global ())
00435 fputs ("stack ", f);
00436 fputs ("address of ", f);
00437 }
00438
00439 switch (Get_const_type()) {
00440
00441 case VALUE_UNKNOWN:
00442 fputs ("*UNKNOWN*", f);
00443 return;
00444
00445 case VALUE_INT_CONST:
00446 fprintf (f, "%lld", Get_int_const_value ());
00447 return;
00448
00449 case VALUE_TWO_CONSTS:
00450 fprintf (f, "0x%x or 0x%x", Get_first_of_two_values(),
00451 Get_second_of_two_values());
00452 return;
00453
00454 case VALUE_CONST:
00455 {
00456 const ST& st = St_Table[Get_const_st_idx ()];
00457 if (ST_sym_class (st) == CLASS_CONST)
00458 fputs (Targ_Print (NULL, Tcon_Table[ST_tcon (st)]), f);
00459 else {
00460 fprintf (f, "GLOBAL %s", ST_name (st));
00461 }
00462 }
00463 return;
00464
00465 case VALUE_FORMAL:
00466 fprintf (f, "FORMAL[%d]", Get_formal_index());
00467 return;
00468
00469 case VALUE_GLOBAL:
00470 fputs ("GLOBAL ", f);
00471 if (Is_global_st_idx()) {
00472 fprintf(f, "ST_IDX = %d", Get_global_st_idx ());
00473 } else {
00474 if (symbol)
00475 symbol[Get_global_index()].Print (f);
00476 else {
00477 if (Get_global_index () != -1)
00478 fprintf (f, "index = %d", Get_global_index ());
00479 else
00480 fprintf (f, "ST_IDX = 0x%x", Get_global_st_idx ());
00481 }
00482 }
00483 return;
00484
00485 case VALUE_SYMBOL:
00486 if (symbol)
00487 symbol[Get_symbol_index()].Print (f);
00488 else
00489 fprintf (f, "Symbol index = %d", Get_symbol_index ());
00490 return;
00491
00492 case VALUE_EXPR:
00493 fprintf (f, "EXPR[%d]", Get_expr_index());
00494 return;
00495
00496 case VALUE_PHI:
00497 fprintf (f, "PHI[%d]", Get_phi_index());
00498 return;
00499
00500 case VALUE_CHI:
00501 fprintf (f, "CHI[%d]", Get_chi_index ());
00502 return;
00503
00504 case VALUE_NOT_CONST:
00505 fputc ('?', f);
00506 return;
00507
00508 }
00509
00510 fputs ("*print function missing*", f);
00511
00512 }
00513
00514
00515 void
00516 SUMMARY_VALUE::Print (FILE *f, INT32 id) const
00517 {
00518 const char *p;
00519
00520 fprintf (f, "VALUE[%d] : ", id);
00521 p = Const_type_name ();
00522 if (p)
00523 fprintf (f, "%s, ", p);
00524 else
00525 fprintf (f, "VALUE_%d, ", Get_const_type());
00526
00527 fprintf (f, "type = %s, ", Get_mtype() == MTYPE_UNKNOWN ? "?" :
00528 MTYPE_name (Get_mtype()));
00529 if (Is_addr_of ())
00530 fprintf (f, "target type = %s, ", Target_mtype() == MTYPE_UNKNOWN ?
00531 "?" : MTYPE_name (Target_mtype()));
00532 fputs ("value = ", f);
00533
00534
00535 Print_const_value (f, Ipl_Summary_Symbol);
00536
00537 fputc ('\n', f);
00538
00539 }
00540
00541
00542 void
00543 SUMMARY_VALUE::Print_array (FILE *f, INT32 size) const
00544 {
00545 fprintf (f, "%sStart value array\n%s", SBar, SBar);
00546 for (INT i = 0; i < size; i++)
00547 this[i].Print (f, i);
00548 fprintf (f, "%sEnd value array\n%s", SBar, SBar );
00549
00550 }
00551
00552
00553 void
00554 SUMMARY_CHI::Print (FILE *f) const
00555 {
00556 fprintf (f, "CALLSITE[%d]: ", Get_call_index ());
00557
00558 switch (_type) {
00559 case CHI_VALUE:
00560 fprintf (f, "VALUE[%d] ", Get_node_index ());
00561 break;
00562 case CHI_PHI:
00563 fprintf (f, "PHI[%d] ", Get_node_index ());
00564 break;
00565 case CHI_EXPR:
00566 fprintf (f, "EXPR[%d] ", Get_node_index ());
00567 break;
00568 case CHI_CHI:
00569 fprintf (f, "CHI[%d] ", Get_node_index ());
00570 break;
00571 }
00572
00573 if (_symbol_index != -1)
00574 Ipl_Summary_Symbol[_symbol_index].Print (f);
00575 else
00576 fputc ('\n', f);
00577
00578 }
00579
00580
00581 void
00582 SUMMARY_CHI::Print_array (FILE *f, INT32 size) const
00583 {
00584 fprintf (f, "%sStart chi array\n%s", SBar, SBar);
00585 for (INT i = 0; i < size; i++) {
00586 fprintf (f, "CHI[%d]: ", i);
00587 this[i].Print (f);
00588 }
00589 fprintf (f, "%sEnd chi array\n%s", SBar, SBar );
00590 }
00591
00592 void
00593 SUMMARY_EXPR::Print_node (FILE *f, INT kid) const
00594 {
00595 if (Is_expr_value (kid))
00596 fprintf (f, " VALUE[%d]", Get_node_index (kid));
00597 else if (Is_expr_phi (kid))
00598 fprintf (f, " PHI[%d]", Get_node_index (kid));
00599 else if (Is_expr_expr (kid))
00600 fprintf (f, " EXPR[%d]", Get_node_index (kid));
00601 else if (Is_expr_chi (kid))
00602 fprintf (f, " CHI[%d]", Get_node_index (kid));
00603
00604 }
00605
00606
00607 void
00608 SUMMARY_EXPR::Print (FILE *f) const
00609 {
00610 if (Is_expr_unknown ()) {
00611 fputs ("unknown\n", f);
00612 return;
00613 }
00614
00615 fputs (Get_opcode() == OPCODE_UNKNOWN
00616 ? "<UNKNOWN>" : OPCODE_name (Get_opcode ()), f);
00617
00618 if (Has_const_operand ()) {
00619 if (Get_kid () == 0) {
00620 Print_node (f);
00621 if (OPCODE_nkids (Get_opcode ()) == 2)
00622 fprintf (f, " 0x%llx", Get_const_value ());
00623 } else {
00624 fprintf (f, " 0x%llx", Get_const_value ());
00625 Print_node (f);
00626 }
00627 } else {
00628
00629 Print_node (f, 0);
00630 Print_node (f, 1);
00631 }
00632
00633 if (Is_trip_count())
00634 fprintf(f, " <TRIP COUNT> ");
00635
00636 fprintf (f, " return type = %s\n", Get_mtype () == MTYPE_UNKNOWN ?
00637 "?" : MTYPE_name (Get_mtype ()));
00638 }
00639
00640
00641 void
00642 SUMMARY_EXPR::Print_array (FILE *f, INT32 size) const
00643 {
00644 fprintf (f, "%sStart expr array\n%s", SBar, SBar);
00645 for (INT i = 0; i < size; i++) {
00646 fprintf (f, "EXPR[%d]: ", i);
00647 this[i].Print (f);
00648 }
00649 fprintf (f, "%sEnd expr array\n%s", SBar, SBar );
00650
00651 }
00652
00653
00654 void
00655 SUMMARY_PHI::Print (FILE *f) const
00656 {
00657 for (INT i = 0; i < 2; i++) {
00658 switch (kids[i]._type) {
00659 case PHI_UNKNOWN:
00660 fprintf (f, "UNKNOWN ");
00661 break;
00662 case PHI_VALUE:
00663 fprintf (f, "VALUE[%d] ", Get_node_index (i));
00664 break;
00665 case PHI_EXPR:
00666 fprintf (f, "EXPR[%d] ", Get_node_index (i));
00667 break;
00668 case PHI_PHI:
00669 fprintf (f, "PHI[%d] ", Get_node_index (i));
00670 break;
00671 case PHI_CHI:
00672 fprintf (f, "CHI[%d] ", Get_node_index (i));
00673 break;
00674 }
00675
00676 fprintf (f, "(if CTRL_DEP[%d] is %s) ", Get_ctrl_dep_index (i),
00677 Get_branch (i) ? "true" : "false");
00678 }
00679
00680 fputc ('\n', f);
00681
00682 }
00683
00684
00685 void
00686 SUMMARY_PHI::Print_array (FILE *f, INT32 size) const
00687 {
00688 fprintf (f, "%sStart phi array\n%s", SBar, SBar);
00689 for (INT i = 0; i < size; i++) {
00690 fprintf (f, "PHI[%d]: ", i);
00691 this[i].Print (f);
00692 }
00693 fprintf (f, "%sEnd phi array\n%s", SBar, SBar );
00694
00695 }
00696
00697
00698
00699 void
00700 SUMMARY_STMT::Print (FILE *f) const
00701 {
00702 switch (_stmt_type) {
00703 case STMT_EXPR:
00704 fprintf (f, "EXPR[%d]\n", Get_expr_index ());
00705 break;
00706 case STMT_VAR:
00707 fprintf(f, "STMT_VAR \n");
00708 Ipl_Summary_Symbol[Get_var_index()].Print (f);
00709 break;
00710 case STMT_CALL:
00711 fprintf (f, "CALLSITE[%d]\n", Get_call_index ());
00712 break;
00713 case STMT_CD:
00714 fprintf (f, "CTRL-DEP[%d]\n", Get_cond_index ());
00715 break;
00716 case STMT_ARRAY_REF:
00717 fprintf (f, "ARRAY map_id = %d\n", Get_array_ref_map_id ());
00718 break;
00719 case STMT_STID:
00720 fprintf (f, "GLOBAL-STID[%d]\n", Get_stid_index());
00721 break;
00722 default:
00723 fprintf(f, "UNKNOWN STMT TYPE\n");
00724 break;
00725 }
00726 }
00727
00728
00729 void
00730 SUMMARY_STMT::Print_array (FILE *f, INT32 size) const
00731 {
00732 fprintf (f, "%sStart stmt array\n%s", SBar, SBar);
00733 for (INT i = 0; i < size; i++) {
00734 fprintf (f, "STMT[%d]: ", i);
00735 this[i].Print (f);
00736 }
00737 fprintf (f, "%sEnd stmt array\n%s", SBar, SBar );
00738 }
00739
00740
00741
00742
00743 void
00744 SUMMARY_CONTROL_DEPENDENCE::Print (FILE *f) const
00745 {
00746 INT i;
00747
00748 if (Is_entry ()) {
00749 fprintf (f, "Entry point:\n");
00750 fprintf (f, "\tStmts, count = %d: ", Get_true_count ());
00751 } if (Is_if_stmt ()) {
00752 fprintf (f, "IF: map_id = %d, EXPR[%d]\n", Get_map_id (),
00753 Get_expr_index ());
00754 fprintf (f, "\tTRUE stmts, count = %d: ", Get_true_count ());
00755 } else if (Is_do_loop ()) {
00756 fprintf (f, "DO LOOP[%d]: map_id = %d\n", Get_do_loop_index (),
00757 Get_map_id ());
00758 fprintf (f, "\tLoop Stmts, count = %d: ", Get_true_count ());
00759 }
00760
00761 for (i = Get_true_stmt_index ();
00762 i < Get_true_stmt_index () + Get_true_count ();
00763 i++)
00764
00765 fprintf (f, "STMT[%d] ", i);
00766 fputc ('\n', f);
00767
00768 if (Is_if_stmt ()) {
00769 fprintf (f, "\tFALSE stmts, count = %d: ", Get_false_count ());
00770
00771 for (i = Get_false_stmt_index ();
00772 i < Get_false_stmt_index () + Get_false_count ();
00773 i++)
00774
00775 fprintf (f, "STMT[%d] ", i);
00776
00777 fputc ('\n', f);
00778 }
00779
00780 }
00781
00782 void
00783 SUMMARY_CONTROL_DEPENDENCE::Print_array (FILE *f, INT32 size) const
00784 {
00785 fprintf (f, "%sStart control dependence array\n%s", SBar, SBar);
00786 for (INT i = 0; i < size; i++) {
00787 fprintf (f, "CTRL-DEP[%d]: ", i);
00788 this[i].Print (f);
00789 }
00790 fprintf (f, "%sEnd control dependence array\n%s", SBar, SBar );
00791
00792 }
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 const char *
00812 SUMMARY_SYMBOL::Get_Name ( void ) const
00813 {
00814
00815 if (Ipl_Summary_Symbol == NULL)
00816 return "";
00817 return ST_name (St_idx ());
00818 }
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836 void
00837 SUMMARY_SYMBOL::Print(FILE *fp,
00838 INT idx,
00839 char* symbol_name,
00840 char* function_name) const
00841 {
00842 INT32 id = -1;
00843
00844
00845 if ((Ipl_Summary_Symbol != NULL ) && (idx == -1)) {
00846 id = this - Ipl_Summary_Symbol;
00847 }
00848
00849 if (idx == -1)
00850 fprintf ( fp, "SYMBOL[%d] ", id );
00851 else
00852 fprintf( fp, "SYMBOL[F%d] ", Get_findex());
00853
00854 INT ss = 0;
00855 if (symbol_name != NULL && function_name != NULL) {
00856 ss = sprintf(Modref_Buf, " \"%s\":\"%s\"", symbol_name, function_name);
00857 } else if (ST_IDX_level(St_idx()) == GLOBAL_SYMTAB) {
00858 ss = sprintf(Modref_Buf, " \"%s\"", ST_name(St_idx()));
00859 }
00860 sprintf(&Modref_Buf[ss],
00861 " type = %s, %sLOCAL, %sSTATIC, %sPASSED(common), %s",
00862 Get_btype () == MTYPE_UNKNOWN ? "?" : MTYPE_name (Get_btype()),
00863 Is_local() ? "" : "non-",
00864 Is_static() ? "" : "non-",
00865 Is_parm() ? "" : "not " ,
00866 Is_common() ? "COMMON, ": "");
00867 fprintf (fp, "%s", Modref_Buf);
00868
00869 if ( IPA_Trace_Mod_Ref ) {
00870 Ipl_record_tlog("MOD_REF", 0, "%s", Modref_Buf);
00871 }
00872
00873 INT32 cc = 0;
00874 if (Is_common_block()) {
00875 fputs (" CBLK", fp);
00876 cc += sprintf(Modref_Buf + cc," COMMON_BLOCK");
00877 }
00878 if (Is_function()) {
00879 fputs (" FUNC", fp);
00880 cc += sprintf(Modref_Buf + cc," FUNCTION");
00881 }
00882 if (Is_imod()) {
00883 fputs (" IMOD", fp);
00884 cc += sprintf(Modref_Buf + cc," IMOD");
00885 }
00886 if (Is_dmod()) {
00887 fputs (" DMOD", fp);
00888 cc += sprintf(Modref_Buf + cc," DMOD");
00889 }
00890 if (Is_iref()) {
00891 fputs (" IREF", fp);
00892 cc += sprintf(Modref_Buf + cc," IREF");
00893 }
00894 if (Is_dref()) {
00895 fputs (" DREF", fp);
00896 cc += sprintf(Modref_Buf + cc," DREF");
00897 }
00898 if (Is_ikill()) {
00899 fputs (" IKILL", fp);
00900 cc += sprintf(Modref_Buf + cc," IKILL");
00901 }
00902 if (Is_dkill()) {
00903 fputs (" DKILL", fp);
00904 cc += sprintf(Modref_Buf + cc," DKILL");
00905 }
00906 if (Is_parm()) {
00907 fputs (" PARM", fp);
00908 cc += sprintf(Modref_Buf + cc," PARM");
00909 }
00910
00911 if (Is_formal()) {
00912 cc += sprintf (Modref_Buf+cc, " FORMAL[%d]", Get_findex ());
00913 fprintf (fp, " FORMAL[%d]", Get_findex ());
00914 }
00915 if (Is_cref()) {
00916 fputs (" CREF", fp);
00917 cc += sprintf(Modref_Buf+cc, " CREF");
00918 }
00919 if (Is_cdref_preg_only() ) {
00920 fputs (" CDREF-PREG-ONLY",fp);
00921 cc += sprintf(Modref_Buf+cc, " CDREF-PREG-ONLY");
00922 }
00923 if (Is_addr_saved() || Is_addr_f90_target() || Is_addr_passed()) {
00924 const char *sep = "";
00925 fputs (" ADDR_TAKEN_AND_", fp );
00926 cc += sprintf( Modref_Buf+cc, " ADDR_TAKEN_AND_ ");
00927 if (Is_addr_saved()) {
00928 fprintf ( fp, "%sSAVED", sep );
00929 cc += sprintf( Modref_Buf+cc, "%sSAVED", sep);
00930 sep = "|";
00931 }
00932 if (Is_addr_f90_target()) {
00933 fprintf ( fp, "%sIS_F90_TARGET", sep );
00934 cc += sprintf( Modref_Buf+cc, "%sIS_F90_TARGET", sep);
00935 sep = "|";
00936 }
00937 if (Is_addr_passed()) {
00938 fprintf ( fp, "%sPASSED", sep );
00939 cc += sprintf( Modref_Buf+cc, "%sPASSED", sep);
00940 }
00941 }
00942 if (Used_in_array_section()) {
00943 fputs(" USED_IN_ARRAY_SECTION", fp);
00944 cc += sprintf( Modref_Buf+cc, " USED_IN_ARRAY_SECTION" );
00945 }
00946 if (Common_io_no_pad()) {
00947 fputs(" I/O", fp);
00948 cc += sprintf( Modref_Buf+cc, " I/O:NO_PAD" );
00949 }
00950 if (Common_read_no_cprop()) {
00951 fputs(" I/O", fp);
00952 cc += sprintf( Modref_Buf+cc, " NO_CPROP" );
00953 }
00954 fputc ('\n', fp );
00955 if ( IPA_Trace_Mod_Ref )
00956 Ipl_record_tlog("MOD_REF", 0, "%s", Modref_Buf);
00957 }
00958
00959
00960
00961 void
00962 SUMMARY_SYMBOL::Trace () const
00963 {
00964 Print ( TFile );
00965 }
00966
00967
00968
00969
00970
00971 void
00972 SUMMARY_SYMBOL::Print_array (FILE* fp, INT32 size,
00973 DYN_ARRAY<char*>* symbol_names,
00974 DYN_ARRAY<char*>* function_names) const
00975 {
00976 INT32 i;
00977
00978 fprintf ( fp, "%sStart symbol array\n%s", SBar, SBar );
00979 for ( i = 0; i< size; ++i ) {
00980 this[i].Print ( fp,
00981 -1,
00982 symbol_names ? (*symbol_names)[i] : NULL,
00983 function_names ? (*function_names)[i] : NULL);
00984 }
00985 fprintf ( fp, "%sEnd symbol array\n%s", SBar, SBar );
00986 }
00987
00988
00989
00990 void
00991 SUMMARY_SYMBOL::Trace_array ( INT32 size ) const
00992 {
00993 Print_array ( TFile, size );
00994 }
00995
00996
00997
00998
00999
01000
01001
01002 void
01003 SUMMARY_GLOBAL::Print ( FILE *fp ) const
01004 {
01005 SUMMARY_SYMBOL *sym = &(Ipl_Summary_Symbol[Get_symbol_index()]);
01006
01007 fprintf ( fp, "GLOBAL %s (refs=%d, mods=%d)",
01008 sym->Get_Name (), Get_refcount(), Get_modcount() );
01009
01010 if ( Is_imod() ) fprintf ( fp, " IMOD");
01011 if ( Is_dmod() ) fprintf ( fp, " DMOD");
01012 if ( Is_iref() ) fprintf ( fp, " IREF");
01013 if ( Is_dref() ) fprintf ( fp, " DREF");
01014 if ( Is_aref() ) fprintf ( fp, " AREF");
01015 if ( Is_ikill() ) fprintf ( fp, " IKILL");
01016 if ( Is_dkill() ) fprintf ( fp, " DKILL");
01017 if ( sym->Is_cref() ) fprintf ( fp, " CREF");
01018 if ( sym->Is_cmod() ) fprintf ( fp, " CMOD");
01019
01020 fprintf ( fp, "\n" );
01021 }
01022
01023
01024
01025 void
01026 SUMMARY_GLOBAL::Trace ( void ) const
01027 {
01028 Print ( TFile );
01029 }
01030
01031
01032
01033
01034
01035 void
01036 SUMMARY_GLOBAL::Print_array (FILE* fp, INT32 size ) const
01037 {
01038 INT i;
01039
01040 fprintf ( fp, "%sStart global array\n%s", SBar, SBar );
01041 for ( i = 0; i< size; ++i ) {
01042 fprintf ( fp, "GLOBAL[%d]: ", i );
01043 this[i].Print ( fp );
01044 }
01045 fprintf ( fp, "%sEnd global array\n%s", SBar, SBar );
01046 }
01047
01048
01049
01050 void
01051 SUMMARY_GLOBAL::Trace_array ( INT32 size ) const
01052 {
01053 Print_array ( TFile, size );
01054 }
01055
01056
01057
01058
01059
01060
01061
01062 void
01063 SUMMARY_COMMON::Print ( FILE *fp, INT32 id ) const
01064 {
01065 fprintf ( fp, "COMMON[%d]: ", id );
01066
01067 if ( Is_initialized() )
01068 fprintf ( fp, ", initialized" );
01069
01070 if ( Has_bad_equiv() )
01071 fprintf ( fp, ", bad equivalence " );
01072
01073 if ( Has_bad_split_equiv() )
01074 fprintf ( fp, ", bad split equivalence " );
01075 else
01076 fprintf ( fp, ", not bad split equivalence ");
01077
01078 if ( Has_array_constants() )
01079 fprintf ( fp, ", array constants " );
01080 else
01081 fprintf ( fp, ", no array constants ");
01082
01083 if ( Has_equivalences() )
01084 fprintf ( fp, ", equivalences " );
01085 else
01086 fprintf ( fp, ", no equivalences " );
01087
01088 if (Has_unstructured_cflow())
01089 fprintf( fp, ", unstructured cflow ");
01090 else
01091 fprintf( fp, ", no unstructured cflow ");
01092
01093 fprintf(fp, "\n");
01094
01095 fprintf ( fp, ", common shape index = %d, common shape count = %d \n",
01096 Get_common_shape_index(), Get_common_shape_count() );
01097
01098 if ( Ipl_Summary_Symbol ) {
01099 Ipl_Summary_Symbol[Get_symbol_index()].Print ( fp );
01100 }
01101 }
01102
01103
01104
01105 void
01106 SUMMARY_COMMON::Trace ( INT32 id ) const
01107 {
01108 Print ( TFile, id );
01109 }
01110
01111
01112 void
01113 SUMMARY_COMMON::Print_array (FILE* fp, INT32 size ) const
01114 {
01115 INT i;
01116
01117 fprintf ( fp, "%sStart common array\n%s", SBar, SBar );
01118 for ( i=0; i<size; ++i ) {
01119 this[i].Print ( fp, i );
01120 }
01121 fprintf ( fp, "%sEnd common array \n%s", SBar, SBar );
01122 }
01123
01124
01125
01126
01127 void
01128 SUMMARY_STID::Print ( FILE *fp, INT32 id ) const
01129 {
01130 fprintf ( fp, "GLOBAL_STID[%d]: ", id );
01131 fprintf ( fp, "symbol index = %d, value index = %d",
01132 Get_symbol_index(), Get_value_index() );
01133 if ( Is_always_executed() )
01134 fprintf ( fp, ", always executed");
01135 if ( Is_array_assignment() ) {
01136 fprintf ( fp, ", array assignment");
01137 if ( Has_constant_subscript() )
01138 fprintf ( fp, ", constant subscript = %d", Get_array_subscript());
01139 else
01140 fprintf ( fp, ", non-constant subscript");
01141 }
01142 fprintf(fp, "\n");
01143 if ( Ipl_Summary_Symbol && Get_symbol_index() != -1 )
01144 Ipl_Summary_Symbol[Get_symbol_index()].Print ( fp );
01145 }
01146
01147
01148 void
01149 SUMMARY_STID::Trace ( INT32 id ) const
01150 {
01151 Print ( TFile, id );
01152 }
01153
01154
01155 void
01156 SUMMARY_STID::Print_array (FILE* fp, INT32 size ) const
01157 {
01158 INT i;
01159
01160 fprintf ( fp, "%sStart STID COMMON array\n%s", SBar, SBar );
01161 for ( i=0; i<size; ++i ) {
01162 this[i].Print ( fp, i );
01163 }
01164 fprintf ( fp, "%sEnd STID COMMON array \n%s", SBar, SBar );
01165 }
01166
01167 void
01168 SUMMARY_STID::Trace_array ( INT32 size ) const
01169 {
01170 Print_array ( TFile, size );
01171 }
01172
01173
01174
01175 void
01176 SUMMARY_COMMON_SHAPE::Print ( FILE *fp, INT32 id ) const
01177 {
01178 fprintf ( fp, "COMMON_SHAPE[%d]: ", id );
01179
01180 if ( Is_kind_array() )
01181 fprintf ( fp, " array" );
01182
01183 if ( Is_kind_scalar() ) {
01184 fprintf ( fp, " scalar, element size = %d, offset = %lld, symbol_id = %d \n", Get_element_size(), Get_offset(), Get_symbol_index());
01185 }
01186
01187 if ( Is_symbolic_bounds() )
01188 fprintf ( fp, ", symbolic bounds \n" );
01189
01190 if (Is_kind_array() && (!Is_symbolic_bounds()))
01191 fprintf (fp,
01192 ", upper = %d, lower = %d, stride = %d, element_size= %d, symbol_id = %d \n",Get_upper(), Get_lower(), Get_stride(),Get_element_size(), Get_symbol_index() );
01193 }
01194
01195
01196
01197
01198 void
01199 SUMMARY_COMMON_SHAPE::Trace ( INT32 id ) const
01200 {
01201 Print ( TFile, id );
01202 }
01203
01204 void
01205 SUMMARY_COMMON_SHAPE::Print_array (FILE* fp, INT32 size ) const
01206 {
01207 INT i;
01208
01209 fprintf ( fp, "%sStart common shape array\n%s", SBar, SBar );
01210 for ( i=0; i<size; ++i ) {
01211 this[i].Print ( fp, i );
01212 }
01213 fprintf ( fp, "%sEnd common shape array \n%s", SBar, SBar );
01214 }
01215
01216
01217
01218 void
01219 SUMMARY_COMMON_SHAPE::Trace_array ( INT32 size ) const
01220 {
01221 Print_array ( TFile, size );
01222 }
01223
01224
01225 void
01226 SUMMARY_STRUCT_ACCESS::Print ( FILE *fp, INT32 id ) const
01227 {
01228 UINT i;
01229 fprintf ( fp, "FLD ACCESS [%d]: name:%s ", id,Get_ty_name() );
01230 for(i=0; i<max_hot_num;i++){
01231 if(Get_hot_fld_id(i)==0)
01232 break;
01233 fprintf ( fp, " field_id= %d, count = %lld \n", Get_hot_fld_id(i),Get_hot_fld(i));
01234 }
01235 }
01236 void
01237 SUMMARY_STRUCT_ACCESS::Trace_array ( INT32 size ) const
01238 {
01239 Print_array ( TFile, size );
01240 }
01241 void
01242 SUMMARY_STRUCT_ACCESS::Print_array (FILE* fp, INT32 size ) const
01243 {
01244 INT i;
01245
01246 fprintf ( fp, "%sStart fld access array\n%s", SBar, SBar );
01247 for ( i=0; i<size; ++i ) {
01248 this[i].Print ( fp, i );
01249 }
01250 fprintf ( fp, "%sEnd fld access array \n%s", SBar, SBar );
01251 }
01252 void
01253 SUMMARY_STRUCT_ACCESS::Trace ( INT32 id ) const
01254 {
01255 Print ( TFile, id );
01256 }
01257
01258 #ifdef KEY
01259 void
01260 SUMMARY_TY_INFO::Print ( FILE *fp ) const
01261 {
01262 fprintf ( fp, "TYPE [%d]: ", Get_ty() );
01263 if (Is_ty_no_split()) fprintf ( fp, "no_split " );
01264
01265 fprintf ( fp, "\n");
01266 }
01267
01268 void
01269 SUMMARY_TY_INFO::Print_array (FILE* fp, INT32 size ) const
01270 {
01271 fprintf ( fp, "%sStart type array\n%s", SBar, SBar );
01272 for ( INT i=0; i<size; ++i ) {
01273 this[i].Print ( fp );
01274 }
01275 fprintf ( fp, "%sEnd type array \n%s", SBar, SBar );
01276 }
01277
01278 void
01279 SUMMARY_TY_INFO::Trace_array ( INT32 size ) const
01280 {
01281 Print_array ( TFile, size );
01282 }
01283
01284 void
01285 SUMMARY_TY_INFO::Trace ( void ) const
01286 {
01287 Print ( TFile );
01288 }
01289 #endif
01290
01291