bool IR_CP::perform(OptCtx & oc) { START_TIMER_AFTER(); ASSERT0(OC_is_cfg_valid(oc)); if (m_prop_kind == CP_PROP_CONST) { m_ru->checkValidAndRecompute(&oc, PASS_DOM, PASS_DU_REF, PASS_DU_CHAIN, PASS_UNDEF); } else { m_ru->checkValidAndRecompute(&oc, PASS_DOM, PASS_DU_REF, PASS_LIVE_EXPR, PASS_DU_CHAIN, PASS_UNDEF); } if (!OC_is_du_chain_valid(oc)) { END_TIMER_AFTER(get_pass_name()); return false; } bool change = false; IRBB * entry = m_ru->get_cfg()->get_entry(); ASSERT(entry, ("Not unique entry, invalid Region")); Graph domtree; m_cfg->get_dom_tree(domtree); List<Vertex*> lst; Vertex * root = domtree.get_vertex(BB_id(entry)); m_cfg->sortDomTreeInPreorder(root, lst); Vector<IR*> usevec; for (Vertex * v = lst.get_head(); v != NULL; v = lst.get_next()) { IRBB * bb = m_cfg->get_bb(VERTEX_id(v)); ASSERT0(bb); change |= doProp(bb, usevec); } if (change) { doFinalRefine(); OC_is_expr_tab_valid(oc) = false; OC_is_aa_valid(oc) = false; OC_is_du_chain_valid(oc) = true; //already update. OC_is_ref_valid(oc) = true; //already update. ASSERT0(m_ru->verifyMDRef() && m_du->verifyMDDUChain()); ASSERT0(verifySSAInfo(m_ru)); } END_TIMER_AFTER(get_pass_name()); return change; }
//GVN try to assign a value numbers to expressions. bool IR_GVN::perform(OPT_CTX & oc) { IR_BB_LIST * bbl = m_ru->get_bb_list(); if (bbl->get_elem_count() == 0) { return false; } START_TIMER_AFTER(); m_ru->check_valid_and_recompute(&oc, OPT_DU_CHAIN, OPT_DU_REF, OPT_RPO, OPT_DOM, OPT_UNDEF); LIST<IR_BB*> * tbbl = m_cfg->get_bblist_in_rpo(); IS_TRUE0(tbbl->get_elem_count() == bbl->get_elem_count()); UINT count = 0; bool change = true; #ifdef DEBUG_GVN while (change && count < 10) { change = false; #endif for (IR_BB * bb = tbbl->get_head(); bb != NULL; bb = tbbl->get_next()) { process_bb(bb, change); } //end for BB count++; #ifdef DEBUG_GVN } //end while IS_TRUE0(!change && count <= 2); #endif //dump(); END_TIMER_AFTER(get_opt_name()); IS_TRUE0(verify()); m_is_valid = true; return true; }
bool PRDF::perform(OptCTX & oc) { START_TIMER_AFTER(); m_ru->checkValidAndRecompute(&oc, PASS_RPO, PASS_UNDEF); List<IRBB*> * bbl = m_ru->get_bb_list(); if (bbl->get_elem_count() == 0) { return false; } List<IR const*> lst; C<IRBB*> * ct; for (bbl->get_head(&ct); ct != bbl->end(); ct = bbl->get_next(ct)) { IRBB * bb = ct->val(); ASSERT0(bb); computeLocal(bb, lst); } computeGlobal(); //dump(); END_TIMER_AFTER(get_pass_name()); return false; }