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 #define __STDC_LIMIT_MACROS
00041 #include <stdint.h>
00042 #if defined(BUILD_OS_DARWIN)
00043 #include <darwin_elf.h>
00044 #else
00045 #include <elf.h>
00046 #endif
00047 #include <cmplrs/host.h>
00048 #include "assert.h"
00049 #define USE_STANDARD_TYPES
00050 #include "defs.h"
00051 #include "cxx_memory.h"
00052 #include "cxx_hash.h"
00053 #include "erglob.h"
00054 #include "glob.h"
00055 #include "mempool.h"
00056 #include "sparse_bv.h"
00057 #include "tracing.h"
00058 #include "strtab.h"
00059 #include "stab.h"
00060 #include "wn.h"
00061 #include "const.h"
00062 #include "pu_info.h"
00063 #include "irbdata.h"
00064 #include "dwarf_DST_mem.h"
00065 #include "ipc_defs.h"
00066 #include "ipc_weak.h"
00067 #include "ipc_file.h"
00068 #include "opt_du.h"
00069 #include "opt_alias_interface.h"
00070 #include "dep_graph.h"
00071 #include "prompf.h"
00072 #include "wb_util.h"
00073 #include "wb_browser.h"
00074 #include "wb.h"
00075 #include "wb_ipa.h"
00076 #include "cg_browser.h"
00077 #include "ipaa.h"
00078 #include "ipa_section_annot.h"
00079 #include "ipa_df.h"
00080 #include "ipa_cprop.h"
00081 #include "ipl_summary.h"
00082 #include "ipa_summary.h"
00083 #include "ipa_cg.h"
00084 #include "ipa_reshape.h"
00085 #include <alloca.h>
00086
00087
00088
00089
00090
00091
00092
00093
00094 extern
00095 PROJECTED_REGION* Projected_Region_To_Memory(IPA_NODE* node,
00096 PROJECTED_REGION* pr,
00097 MEM_POOL* mem_pool)
00098 {
00099 PROJECTED_REGION* pr_memory = CXX_NEW(PROJECTED_REGION(pr->Get_type(),
00100 pr->Get_depth(),
00101 pr->Get_num_dims(),
00102 mem_pool), mem_pool);
00103 if (pr->Is_messy_region()) {
00104 return pr_memory;
00105 }
00106
00107 pr_memory->Set_projected_array(CXX_NEW(PROJECTED_ARRAY(mem_pool), mem_pool));
00108 PROJECTED_NODE* pn = &IPA_get_projected_node_array(node)[pr->Get_id()];
00109 INT pr_count = pr->Get_num_dims();
00110 PROJECTED_NODE* pn_memory =
00111 TYPE_MEM_POOL_ALLOC_N(PROJECTED_NODE, mem_pool, pr_count);
00112 bcopy(pn, pn_memory, pr_count * sizeof(PROJECTED_NODE));
00113 TERM* term_array = IPA_get_term_array(node);
00114 for (INT i = 0; i < pr_count; i++) {
00115 pn_memory[i].Set_Mem_Pool(mem_pool);
00116 pn_memory[i].Create_linex(term_array);
00117 pr_memory->Set_projected_node(&pn_memory[i]);
00118 }
00119 return pr_memory;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128 static REGION_ARRAYS*
00129 Region_To_Memory(IPA_NODE* node,
00130 REGION_ARRAYS* ra,
00131 MEM_POOL* mem_pool)
00132 {
00133 FmtAssert(ra != NULL,
00134 ("Region_To_Memory: Expecting non-NULL REGION_ARRAYS"));
00135 INT symbol_index = ra->Get_sym_id();
00136 REGION_ARRAYS* ra_new
00137 = CXX_NEW(REGION_ARRAYS(mem_pool, symbol_index), mem_pool);
00138 PROJECTED_REGION_INFO_ARRAY* pria_new = ra_new->Get_projected_region_array();
00139 PROJECTED_REGION* proj_region_array = IPA_get_proj_region_array(node);
00140 for (INT i = ra->Get_idx(); i < ra->Get_idx() + ra->Get_count(); i++) {
00141 PROJECTED_REGION* pr = &proj_region_array[i];
00142 PROJECTED_REGION* pr_new = Projected_Region_To_Memory(node,
00143 pr, mem_pool);
00144 INT idx = pria_new->Newidx();
00145 PROJECTED_REGION_INFO* pri_new = &((*pria_new)[idx]);
00146 pri_new->Set_projected_region(pr_new);
00147 }
00148 ra_new->Set_count(ra->Get_count());
00149 ra_new->Set_element_size(ra->Get_element_size());
00150 return ra_new;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160 static PROJECTED_REGION*
00161 Formal_Projected_Region(REGION_ARRAYS* ra)
00162 {
00163 FmtAssert(ra->Get_count() == 1,
00164 ("Formal_Projected_Region: Expecting single projected region"));
00165 PROJECTED_REGION_INFO_ARRAY* pria = ra->Get_projected_region_array();
00166 PROJECTED_REGION_INFO* pri = &(*pria)[0];
00167 return pri->Get_projected_region();
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 static REGION_ARRAYS* Translate_Array(IPA_NODE* ipan_caller,
00180 IPA_NODE* ipan_callee,
00181 SUMMARY_CALLSITE* sk,
00182 INT position,
00183 MEM_POOL* mem_pool)
00184 {
00185 FmtAssert(position >= 0 && position < sk->Get_param_count(),
00186 ("Translate_Through_Call: 'position' out of range"));
00187 INT actual_index = sk->Get_actual_index() + position;
00188 SUMMARY_ACTUAL* actual_array = IPA_get_actual_array(ipan_caller);
00189 SUMMARY_ACTUAL* sa = &actual_array[actual_index];
00190 INT symbol_index = sa->Get_symbol_index();
00191 if (symbol_index == -1)
00192 return NULL;
00193 SUMMARY_PROCEDURE* sp_callee = ipan_callee->Summary_Proc();
00194 FmtAssert(position >= 0 && position < sp_callee->Get_formal_count(),
00195 ("Translate_Array: 'position' out of range"));
00196 INT formal_index = sp_callee->Get_formal_index() + position;
00197 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(ipan_callee);
00198 SUMMARY_FORMAL* sf = &formal_array[formal_index];
00199 INT region_index = sf->Get_region_index();
00200 if (region_index == -1)
00201 return NULL;
00202 REGION_ARRAYS* region_array = IPA_get_region_array(ipan_callee);
00203 REGION_ARRAYS* ra = ®ion_array[region_index];
00204 FmtAssert(ra->Get_count() == 1,
00205 ("Translate_Array: Expecting single projected region in formal"));
00206 FmtAssert(ra->Is_formal(), ("Translate_Array: Expecting a formal"));
00207 INT pr_index = ra->Get_idx();
00208 PROJECTED_REGION* proj_region_array
00209 = IPA_get_proj_region_array(ipan_callee);
00210 PROJECTED_REGION* pr = &proj_region_array[pr_index];
00211 PROJECTED_REGION* pr_memory = Projected_Region_To_Memory(ipan_callee, pr,
00212 mem_pool);
00213 PROJECTED_REGION* pr_new = CXX_NEW(PROJECTED_REGION(MESSY_REGION, 0,
00214 pr->Get_num_dims(), mem_pool), mem_pool);
00215 Map_callee_region_to_caller(ipan_caller, ipan_callee, sk, pr_new, pr_memory);
00216 REGION_ARRAYS* ra_new
00217 = CXX_NEW(REGION_ARRAYS(mem_pool, symbol_index), mem_pool);
00218 PROJECTED_REGION_INFO_ARRAY* pria_new = ra_new->Get_projected_region_array();
00219 INT idx = pria_new->Newidx();
00220 PROJECTED_REGION_INFO* pri_new = &((*pria_new)[idx]);
00221 pri_new->Set_projected_region(pr_new);
00222 ra_new->Set_count(1);
00223 ra_new->Set_element_size(ra->Get_element_size());
00224 return ra_new;
00225 }
00226
00227
00228
00229
00230
00231
00232
00233 static BOOL Is_Scalar(IPA_NODE* node,
00234 SUMMARY_SYMBOL* ss)
00235 {
00236 if (ss->Is_formal()) {
00237 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(node);
00238 SUMMARY_FORMAL* sf = &formal_array[ss->Get_findex()];
00239 return sf->Get_region_index() == -1;
00240 } else if (ST_IDX_level(ss->St_idx()) == GLOBAL_SYMTAB) {
00241 return TY_kind(ST_type(ss->St_idx())) != KIND_ARRAY;
00242 } else {
00243 return !ss->Is_array();
00244 }
00245 }
00246
00247
00248
00249
00250
00251
00252
00253 static REGION_ARRAYS*
00254 Formal_Region_Arrays(IPA_NODE* node,
00255 SUMMARY_SYMBOL* ss)
00256 {
00257 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(node);
00258 SUMMARY_FORMAL* sf = &formal_array[ss->Get_findex()];
00259 REGION_ARRAYS* region_array = IPA_get_region_array(node);
00260 REGION_ARRAYS* ra = NULL;
00261 if (sf->Get_region_index() != -1)
00262 ra = ®ion_array[sf->Get_region_index()];
00263 return ra;
00264 }
00265
00266
00267
00268
00269
00270
00271
00272 static PROJECTED_REGION *
00273 Formal_Projected_Region(IPA_NODE* node, SUMMARY_SYMBOL *s)
00274 {
00275 REGION_ARRAYS *r = Formal_Region_Arrays(node, s);
00276 return Formal_Projected_Region(r);
00277 }
00278
00279
00280
00281
00282
00283
00284
00285
00286 static INT Dim_Count(IPA_NODE* node,
00287 SUMMARY_SYMBOL* ss)
00288 {
00289 if (ss->Is_formal()) {
00290 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(node);
00291 SUMMARY_FORMAL* sf = &formal_array[ss->Get_findex()];
00292 REGION_ARRAYS* region_array = IPA_get_region_array(node);
00293 REGION_ARRAYS* ra = ®ion_array[sf->Get_region_index()];
00294 return ra->Get_count();
00295 }
00296 else if (ST_IDX_level(ss->St_idx()) == GLOBAL_SYMTAB) {
00297 return TY_AR_ndims(ST_type(ss->St_idx()));
00298 }
00299 else {
00300 return -1;
00301 }
00302 }
00303
00304
00305
00306
00307
00308
00309
00310 static INT Dim_Size(SUMMARY_SYMBOL* ss,
00311 INT dim)
00312 {
00313 TY_IDX ty_idx = ST_type(ss->St_idx());
00314 return TY_AR_ubnd_val(ty_idx,dim) - TY_AR_lbnd_val(ty_idx,dim) + 1;
00315 }
00316
00317
00318
00319
00320
00321
00322
00323 static INT Formal_Dim_Count(REGION_ARRAYS* ra)
00324 {
00325 PROJECTED_REGION* pr = Formal_Projected_Region(ra);
00326 return pr->Get_num_dims();
00327 }
00328
00329
00330
00331
00332
00333
00334
00335 static BOOL Are_Equal_Dims(REGION_ARRAYS* ra_caller,
00336 REGION_ARRAYS* ra_callee,
00337 INT position)
00338 {
00339
00340 PROJECTED_REGION* pr_caller = Formal_Projected_Region(ra_caller);
00341 PROJECTED_NODE* pn_caller = pr_caller->Get_projected_node(position);
00342
00343 if (pn_caller->Is_messy_lb() || pn_caller->Is_messy_ub()
00344 || pn_caller->Is_messy_step())
00345 return FALSE;
00346 PROJECTED_REGION* pr_callee = Formal_Projected_Region(ra_callee);
00347 PROJECTED_NODE* pn_callee = pr_callee->Get_projected_node(position);
00348
00349 if (pn_callee->Is_messy_lb() || pn_callee->Is_messy_ub()
00350 || pn_callee->Is_messy_step())
00351 return FALSE;
00352 LINEX* lx_lb_caller = pn_caller->Get_lower_linex();
00353 LINEX* lx_lb_callee = pn_callee->Get_lower_linex();
00354 if (!lx_lb_caller->Equivalent(*lx_lb_callee))
00355 return FALSE;
00356 LINEX* lx_ub_caller = pn_caller->Get_upper_linex();
00357 LINEX* lx_ub_callee = pn_callee->Get_upper_linex();
00358 if (!lx_ub_caller->Equivalent(*lx_ub_callee))
00359 return FALSE;
00360 LINEX* lx_step_caller = pn_caller->Get_step_linex();
00361 LINEX* lx_step_callee = pn_callee->Get_step_linex();
00362 if (!lx_step_caller->Equivalent(*lx_step_callee))
00363 return FALSE;
00364 return TRUE;
00365 }
00366
00367
00368
00369
00370
00371
00372
00373
00374 static BOOL Constant_Linex_Value(LINEX* lx,
00375 INT64* value)
00376 {
00377 INT64 local_value = 0;
00378 for (INT i = 0; i <= lx->Num_terms(); i++) {
00379 TERM* tm = lx->Get_term(i);
00380 if (tm->Get_type() != LTKIND_CONST)
00381 return FALSE;
00382 local_value += tm->Get_coeff();
00383 }
00384 *value = local_value;
00385 return TRUE;
00386 }
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 static BOOL Are_Equal_Dims(SUMMARY_SYMBOL* ss_caller,
00398 REGION_ARRAYS* ra_callee,
00399 INT position)
00400 {
00401 Is_True(ST_IDX_level(ss_caller->St_idx()) == GLOBAL_SYMTAB,
00402 ("Are_Equal_Dims: Expected a global symbol"));
00403 PROJECTED_REGION* pr_callee = Formal_Projected_Region(ra_callee);
00404 PROJECTED_NODE* pn_callee = pr_callee->Get_projected_node(position);
00405
00406 if (pn_callee->Is_messy_lb() || pn_callee->Is_messy_ub()
00407 || pn_callee->Is_messy_step())
00408 return FALSE;
00409 INT64 caller_dim_size = Dim_Size(ss_caller, position);
00410 LINEX* lx_lb_callee = pn_callee->Get_lower_linex();
00411 INT64 lx_lower_value = 0;
00412 if (!Constant_Linex_Value(lx_lb_callee, &lx_lower_value))
00413 return FALSE;
00414 LINEX* lx_ub_callee = pn_callee->Get_upper_linex();
00415 INT64 lx_upper_value = 0;
00416 if (!Constant_Linex_Value(lx_ub_callee, &lx_upper_value))
00417 return FALSE;
00418 INT64 callee_dim_size = lx_upper_value - lx_lower_value + 1;
00419 if (caller_dim_size != callee_dim_size)
00420 return FALSE;
00421 return TRUE;
00422 }
00423
00424
00425
00426
00427
00428 extern BOOL
00429 Mismatched_Types(IPA_NODE* ipan_caller,
00430 IPA_NODE* ipan_callee,
00431 SUMMARY_CALLSITE *sk,
00432 INT position,
00433 MEM_POOL *mem_pool)
00434 {
00435 FmtAssert(position >= 0 && position < sk->Get_param_count(),
00436 ("Translate_Through_Call: 'position' out of range"));
00437 SUMMARY_ACTUAL* actual_array = IPA_get_actual_array(ipan_caller);
00438 INT actual_index = sk->Get_actual_index() + position;
00439 SUMMARY_ACTUAL* sa = &actual_array[actual_index];
00440 SUMMARY_SYMBOL* cr_symbol_array = IPA_get_symbol_array(ipan_caller);
00441 switch (sa->Get_pass_type()) {
00442
00443 case PASS_LOAD:
00444 case PASS_MLOAD:
00445 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00446 fprintf(stdout, "SHAPE: Odd Pass Type in %s calling %s ARG %d\n",
00447 ipan_caller->Name(), ipan_callee->Name(), position);
00448 return TRUE;
00449 case PASS_LDID:
00450 case PASS_LDA: {
00451 SUMMARY_PROCEDURE* sp = ipan_callee->Summary_Proc();
00452 INT formal_base_index = sp->Get_formal_index();
00453 INT formal_count = sp->Get_formal_count();
00454 if (!(position >= 0 && position < formal_count))
00455 return TRUE;
00456 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(ipan_callee);
00457 SUMMARY_FORMAL* sf = &formal_array[formal_base_index + position];
00458 INT symbol_index = sf->Get_symbol_index();
00459 SUMMARY_SYMBOL* symbol_array = IPA_get_symbol_array(ipan_callee);
00460 SUMMARY_SYMBOL* ss = &symbol_array[symbol_index];
00461 if (!ss->Is_dmod() && !ss->Is_imod() && !ss->Is_ref())
00462 return FALSE;
00463 }
00464 break;
00465
00466
00467 case PASS_ARRAY_SECTION:
00468 break;
00469
00470 case PASS_UNKNOWN:
00471 break;
00472
00473 default:
00474 FmtAssert(TRUE, ("Try_Reshape: Unexpected pass type"));
00475 break;
00476 }
00477 INT caller_symbol_index = sa->Get_symbol_index();
00478 if (caller_symbol_index == -1) {
00479
00480 if (sa->Get_value_index() != -1)
00481 return FALSE;
00482 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00483 fprintf(stdout,
00484 "SHAPE: Unknown Actual Symbol Index in %s calling %s ARG %d\n",
00485 ipan_caller->Name(), ipan_callee->Name(), position);
00486 return TRUE;
00487 }
00488 SUMMARY_PROCEDURE* sp_callee = ipan_callee->Summary_Proc();
00489 INT formal_index = sp_callee->Get_formal_index();
00490 SUMMARY_FORMAL* ce_formal_array = IPA_get_formal_array(ipan_callee);
00491 SUMMARY_FORMAL* sf = &ce_formal_array[formal_index + position];
00492 INT callee_symbol_index = sf->Get_symbol_index();
00493 SUMMARY_SYMBOL* ce_symbol_array = IPA_get_symbol_array(ipan_callee);
00494 SUMMARY_SYMBOL* ss_caller = &cr_symbol_array[caller_symbol_index];
00495 SUMMARY_SYMBOL* ss_callee = &ce_symbol_array[callee_symbol_index];
00496
00497
00498 if (sf->Get_region_index() == -1) {
00499 if (Is_Scalar(ipan_caller, ss_caller))
00500 return FALSE;
00501 }
00502 if (Is_Scalar(ipan_caller, ss_caller)) {
00503 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00504 fprintf(stdout,
00505 "SHAPE: Scalar Passed to Array in %s calling %s ARG %d\n",
00506 ipan_caller->Name(), ipan_callee->Name(), position);
00507 return TRUE;
00508 }
00509
00510 REGION_ARRAYS* ra_callee
00511 = Translate_Array(ipan_caller, ipan_callee, sk, position, mem_pool);
00512 if (ra_callee == NULL) {
00513 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00514 fprintf(stdout,
00515 "SHAPE: Could not Translate_Array in %s calling %s ARG %d\n",
00516 ipan_caller->Name(), ipan_callee->Name(), position);
00517 return TRUE;
00518 }
00519 if (ss_caller->Is_formal()) {
00520 REGION_ARRAYS* ra_caller = Formal_Region_Arrays(ipan_caller, ss_caller);
00521 ra_caller = Region_To_Memory(ipan_caller, ra_caller, mem_pool);
00522 if (ra_caller->Get_element_size() != ra_callee->Get_element_size()) {
00523 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00524 fprintf(stdout,
00525 "SHAPE: Mismatched base sizes in %s calling %s ARG %d\n",
00526 ipan_caller->Name(), ipan_callee->Name(), position);
00527 return TRUE;
00528 }
00529 }
00530 else if (ST_IDX_level(ss_caller->St_idx()) == GLOBAL_SYMTAB) {
00531 #if 0
00532
00533 #endif
00534 if (TY_size(TY_etype(ST_type(ss_caller->St_idx())))
00535 != ra_callee->Get_element_size()) {
00536 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00537 fprintf(stdout,
00538 "Reshape: Mismatched base sizes in %s calling %s ARG %d\n",
00539 ipan_caller->Name(), ipan_callee->Name(), position);
00540 return TRUE;
00541 }
00542 }
00543 return FALSE;
00544 }
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554 extern BOOL Try_Reshape_Callee_Formal(IPA_NODE* ipan_caller,
00555 IPA_NODE* ipan_callee,
00556 SUMMARY_CALLSITE* sk,
00557 INT position,
00558 MEM_POOL* mem_pool)
00559 {
00560 FmtAssert(position >= 0 && position < sk->Get_param_count(),
00561 ("Translate_Through_Call: 'position' out of range"));
00562 INT actual_index = sk->Get_actual_index() + position;
00563 SUMMARY_ACTUAL* sa = &IPA_get_actual_array(ipan_caller)[actual_index];
00564 SUMMARY_SYMBOL* cr_symbol_array = IPA_get_symbol_array(ipan_caller);
00565 switch (sa->Get_pass_type()) {
00566 case PASS_UNKNOWN:
00567
00568 case PASS_LOAD:
00569 case PASS_MLOAD:
00570 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00571 fprintf(stdout, "SHAPE: Odd Pass Type in %s calling %s ARG %d\n",
00572 ipan_caller->Name(), ipan_callee->Name(), position);
00573 return TRUE;
00574 case PASS_ARRAY_SECTION:
00575 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00576 fprintf(stdout, "SHAPE: Array Section in %s calling %s ARG %d\n",
00577 ipan_caller->Name(), ipan_callee->Name(), position);
00578 return TRUE;
00579 case PASS_LDID:
00580 case PASS_LDA: {
00581 SUMMARY_PROCEDURE* sp = ipan_callee->Summary_Proc();
00582 INT formal_base_index = sp->Get_formal_index();
00583 INT formal_count = sp->Get_formal_count();
00584 if (!(position >= 0 && position < formal_count))
00585 return TRUE;
00586 SUMMARY_FORMAL* formal_array = IPA_get_formal_array(ipan_callee);
00587 SUMMARY_FORMAL* sf = &formal_array[formal_base_index + position];
00588 INT symbol_index = sf->Get_symbol_index();
00589 SUMMARY_SYMBOL* symbol_array = IPA_get_symbol_array(ipan_callee);
00590 SUMMARY_SYMBOL* ss = &symbol_array[symbol_index];
00591 if (!ss->Is_dmod() && !ss->Is_imod())
00592 return FALSE;
00593 }
00594 break;
00595 default:
00596 FmtAssert(TRUE, ("Try_Reshape: Unexpected pass type"));
00597 break;
00598 }
00599 INT caller_symbol_index = sa->Get_symbol_index();
00600 if (caller_symbol_index == -1) {
00601
00602 if (sa->Get_value_index() != -1)
00603 return FALSE;
00604 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00605 fprintf(stdout,
00606 "SHAPE: Unknown Actual Symbol Index in %s calling %s ARG %d\n",
00607 ipan_caller->Name(), ipan_callee->Name(), position);
00608 return TRUE;
00609 }
00610 SUMMARY_PROCEDURE* sp_callee = ipan_callee->Summary_Proc();
00611 INT formal_index = sp_callee->Get_formal_index();
00612 SUMMARY_FORMAL* ce_formal_array = IPA_get_formal_array(ipan_callee);
00613 SUMMARY_FORMAL* sf = &ce_formal_array[formal_index + position];
00614 INT callee_symbol_index = sf->Get_symbol_index();
00615 SUMMARY_SYMBOL* ce_symbol_array = IPA_get_symbol_array(ipan_callee);
00616 SUMMARY_SYMBOL* ss_caller = &cr_symbol_array[caller_symbol_index];
00617 SUMMARY_SYMBOL* ss_callee = &ce_symbol_array[callee_symbol_index];
00618 if (sf->Get_region_index() == -1) {
00619 if (Is_Scalar(ipan_caller, ss_caller)) {
00620 return FALSE;
00621 }
00622 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00623 fprintf(stdout,
00624 "SHAPE: Array Passed to Scalar in %s calling %s ARG %d\n",
00625 ipan_caller->Name(), ipan_callee->Name(), position);
00626 return TRUE;
00627 }
00628 if (Is_Scalar(ipan_caller, ss_caller)) {
00629 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00630 fprintf(stdout,
00631 "SHAPE: Scalar Passed to Array in %s calling %s ARG %d\n",
00632 ipan_caller->Name(), ipan_callee->Name(), position);
00633 return TRUE;
00634 }
00635 REGION_ARRAYS* ra_callee
00636 = Translate_Array(ipan_caller, ipan_callee, sk, position, mem_pool);
00637 if (ra_callee == NULL) {
00638 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00639 fprintf(stdout,
00640 "SHAPE: Could not Translate_Array in %s calling %s ARG %d\n",
00641 ipan_caller->Name(), ipan_callee->Name(), position);
00642 return TRUE;
00643 }
00644 if (ss_caller->Is_formal()) {
00645 REGION_ARRAYS* ra_caller = Formal_Region_Arrays(ipan_caller, ss_caller);
00646 ra_caller = Region_To_Memory(ipan_caller, ra_caller, mem_pool);
00647 if (ra_caller->Get_element_size() != ra_callee->Get_element_size()) {
00648 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00649 fprintf(stdout,
00650 "SHAPE: Mismatched base sizes in %s calling %s ARG %d\n",
00651 ipan_caller->Name(), ipan_callee->Name(), position);
00652 return TRUE;
00653 }
00654 if (Formal_Dim_Count(ra_caller) != Formal_Dim_Count(ra_callee)) {
00655 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00656 fprintf(stdout,
00657 "TRY RESHAPE: Mismatched Array Dims in %s calling %s ARG %d\n",
00658 ipan_caller->Name(), ipan_callee->Name(), position);
00659 return TRUE;
00660 }
00661 INT dim_count = Formal_Dim_Count(ra_caller);
00662 for (INT i = 1; i < dim_count; i++) {
00663 if (!Are_Equal_Dims(ra_caller, ra_callee, i)) {
00664 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00665 fprintf(stdout,
00666 "SHAPE: Mismatched Array Subs in %s calling %s ARG %d\n",
00667 ipan_caller->Name(), ipan_callee->Name(), position);
00668 return TRUE;
00669 }
00670 }
00671 }
00672 else if (ST_IDX_level(ss_caller->St_idx()) == GLOBAL_SYMTAB) {
00673 #if 0
00674
00675 #endif
00676 if (TY_size(TY_etype(ST_type(ss_caller->St_idx())))
00677 != ra_callee->Get_element_size()) {
00678 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00679 fprintf(stdout,
00680 "SHAPE: Mismatched base sizes in %s calling %s ARG %d\n",
00681 ipan_caller->Name(), ipan_callee->Name(), position);
00682 return TRUE;
00683 }
00684 if (Dim_Count(ipan_caller, ss_caller) != Formal_Dim_Count(ra_callee)) {
00685 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00686 fprintf(stdout,
00687 "TRY RESHAPE: Mismatched Array Dims in %s calling %s ARG %d\n",
00688 ipan_caller->Name(), ipan_callee->Name(), position);
00689 return TRUE;
00690 }
00691 INT dim_count = Dim_Count(ipan_caller, ss_caller);
00692 for (INT i = 1; i < dim_count; i++) {
00693 if (!Are_Equal_Dims(ss_caller, ra_callee, i)) {
00694 if (Get_Trace(TP_IPA, IPA_TRACE_SECTION_CORRECTNESS))
00695 fprintf(stdout,
00696 "TRY RESHAPE: Mismatched Array Subs in %s calling %s ARG %d\n",
00697 ipan_caller->Name(), ipan_callee->Name(), position);
00698 return TRUE;
00699 }
00700 }
00701 }
00702 return FALSE;
00703 }