bool DUSet::verify_def(IR_DU_MGR * du) const { CK_USE(du); DU_ITER di = NULL; for (UINT d = get_first(&di); di != NULL; d = get_next(d, &di)) { ASSERT0(du->get_ir(d)->is_stmt()); } return true; }
bool DUSet::verify_use(IR_DU_MGR * du) const { CK_USE(du); DU_ITER di = NULL; for (UINT u = get_first(&di); di != NULL; u = get_next(u, &di)) { ASSERT0(du->get_ir(u)->is_exp()); } return true; }
//Return true if 'occ' does not be modified till meeting 'use_ir'. //e.g: // xx = occ //def_ir // .. // .. // yy = xx //use_ir // //'def_ir': ir stmt. //'occ': opnd of 'def_ir' //'use_ir': stmt in use-list of 'def_ir'. bool IR_CP::is_available(IR const* def_ir, IR const* occ, IR * use_ir) { if (def_ir == use_ir) { return false; } if (occ->is_const()) { return true; } //Need check overlapped MDSet. //e.g: Suppose occ is '*p + *q', p->a, q->b. //occ can NOT reach 'def_ir' if one of p, q, a, b //modified during the path. IRBB * defbb = def_ir->get_bb(); IRBB * usebb = use_ir->get_bb(); if (defbb == usebb) { //Both def_ir and use_ir are in same BB. C<IR*> * ir_holder = NULL; bool f = BB_irlist(defbb).find(const_cast<IR*>(def_ir), &ir_holder); CK_USE(f); IR * ir; for (ir = BB_irlist(defbb).get_next(&ir_holder); ir != NULL && ir != use_ir; ir = BB_irlist(defbb).get_next(&ir_holder)) { if (m_du->is_may_def(ir, occ, true)) { return false; } } if (ir == NULL) { ;//use_ir appears prior to def_ir. Do more check via live_in_expr. } else { ASSERT(ir == use_ir, ("def_ir should be in same bb to use_ir")); return true; } } ASSERT0(use_ir->is_stmt()); DefDBitSetCore const* availin_expr = m_du->getAvailInExpr(BB_id(usebb), NULL); ASSERT0(availin_expr); if (availin_expr->is_contain(IR_id(occ))) { IR * u; for (u = BB_first_ir(usebb); u != use_ir && u != NULL; u = BB_next_ir(usebb)) { //Check if 'u' override occ's value. if (m_du->is_may_def(u, occ, true)) { return false; } } ASSERT(u != NULL && u == use_ir, ("Not find use_ir in bb, may be it has " "been removed by other optimization")); return true; } return false; }