| 454 | } |
| 455 | |
| 456 | bool FindComparesInUseChain(int defBlk, mop_t* cmpVar) |
| 457 | { |
| 458 | mbl_graph_t* graph = mba->get_graph(); |
| 459 | if (graph->is_du_chain_dirty(GC_REGS_AND_STKVARS)) { |
| 460 | MSG_UF2(("[W] du chain is dirty\n")); |
| 461 | return false; |
| 462 | } |
| 463 | chain_keeper_t du = graph->get_du(GC_REGS_AND_STKVARS); |
| 464 | |
| 465 | const block_chains_t& bc = du[defBlk]; |
| 466 | const chain_t* ch = bc.get_chain(*cmpVar, cmpVar->size); |
| 467 | if (ch == NULL) { |
| 468 | MSG_UF2(("[W] no def/use chain for %s def %d\n", cmpVar->dstr(), defBlk)); |
| 469 | //mba->get_mblock(defBlk)->build_lists(false); // doesnt help |
| 470 | return false; |
| 471 | } |
| 472 | mlist_t list; |
| 473 | mba->get_mblock(defBlk)->append_use_list(&list, *cmpVar, MUST_ACCESS); |
| 474 | |
| 475 | for (size_t i = 0; i < ch->size(); i++) { |
| 476 | int bn = ch->at(i); |
| 477 | mblock_t* blk = mba->get_mblock(bn); // block that uses the instruction |
| 478 | minsn_t* ins = blk->head; |
| 479 | |
| 480 | //walk all instructions in block to be sure our Use of cmpVar has not been redefined before compare |
| 481 | for (minsn_t* p = ins; p != NULL && !list.empty(); p = p->next) { |
| 482 | mlist_t use = blk->build_use_list(*p, MUST_ACCESS); // things used by the insn |
| 483 | mlist_t def = blk->build_def_list(*p, MUST_ACCESS); // things defined by the insn |
| 484 | if (list.has_common(use)) { |
| 485 | if (p != blk->tail || !addCmp(blk)) { |
| 486 | MSG_UF2(("[W] %a: found strange use cmpVar '%s' at %d\n", p->ea, p->dstr(), bn)); |
| 487 | } |
| 488 | } |
| 489 | list.sub(def); |
| 490 | } |
| 491 | } |
| 492 | return true; |
| 493 | } |
| 494 | |
| 495 | int FindBlockByKey(Key_t key) |
| 496 | { |