bool DexRegion::HighProcess(OptCtx & oc) { CHAR const* ru_name = getRegionName(); g_indent = 0; SimpCtx simp; SIMP_if(&simp) = true; SIMP_doloop(&simp) = true; SIMP_dowhile(&simp) = true; SIMP_whiledo(&simp) = true; SIMP_switch(&simp) = false; SIMP_break(&simp) = true; SIMP_continue(&simp) = true; setIRList(simplifyStmtList(getIRList(), &simp)); ASSERT0(verify_simp(getIRList(), simp)); ASSERT0(verify_irs(getIRList(), NULL, this)); constructIRBBlist(); ASSERT0(verifyIRandBB(getBBList(), this)); //All IRs have been moved to each IRBB. setIRList(NULL); HighProcessImpl(oc); return true; }
bool DEX_REGION::high_process(OPT_CTX & oc) { CHAR const* ru_name = get_ru_name(); g_indent = 0; SIMP_CTX simp; SIMP_if(&simp) = 1; SIMP_do_loop(&simp) = 1; SIMP_do_while(&simp) = 1; SIMP_while_do(&simp) = 1; SIMP_switch(&simp) = 0; SIMP_break(&simp) = 1; SIMP_continue(&simp) = 1; RU_ana(this)->m_ir_list = simplify_stmt_list(get_ir_list(), &simp); IS_TRUE0(verify_simp(get_ir_list(), simp)); IS_TRUE0(verify_irs(get_ir_list(), NULL, get_dm())); construct_ir_bb_list(); IS_TRUE0(verify_ir_and_bb(get_bb_list(), get_dm())); RU_ana(this)->m_ir_list = NULL; //All IRs have been moved to each IR_BB. IS_TRUE0(g_do_cfg && g_do_aa && g_do_du_ana && g_do_cdg); IR_CFG * cfg = init_cfg(oc); cfg->loop_analysis(oc); if (g_do_ssa && OPTC_pass_mgr(oc) != NULL) { IR_SSA_MGR * ssamgr = (IR_SSA_MGR*)OPTC_pass_mgr(oc)-> register_opt(OPT_SSA_MGR); IS_TRUE0(ssamgr); ssamgr->construction(oc, this); } init_aa(oc); init_du(oc); if (g_opt_level == NO_OPT) { return false; } return true; }
//Control flow structure optimization and up to bottom walk through //the IR tree. High level IRs include IR_IF, IR_WHILE_DO... //High Level Reshaping phase consist of: // 1. goto reduction // 2. if restructure // 3. loop restructure bool IR_CFS_OPT::perform(SimpCtx const& sc) { ASSERT0(!SIMP_if(&sc) && !SIMP_doloop(&sc) && !SIMP_dowhile(&sc) && !SIMP_whiledo(&sc) && !SIMP_switch(&sc) && !SIMP_break(&sc) && !SIMP_continue(&sc)); if (!g_do_cfs_opt) { return false; } IR * irs = m_ru->getIRList(); bool change = CfsOpt(&irs, sc); if (change) { m_ru->setIRList(irs); } return change; }
/* Control flow structure optimization and up to bottom walk through the IR tree. High level IRs include IR_IF, IR_WHILE_DO... High Level Reshaping phase consist of: 1. goto reduction 2. if restructure 3. loop restructure */ bool IR_CFS_OPT::perform(IN SIMP_CTX const& sc) { IS_TRUE0(!SIMP_if(&sc) && !SIMP_do_loop(&sc) && !SIMP_do_while(&sc) && !SIMP_while_do(&sc) && !SIMP_switch(&sc) && !SIMP_break(&sc) && !SIMP_continue(&sc)); if (g_opt_level == NO_OPT) { return false; } IR * irs = m_ru->get_ir_list(); bool change = perform_cfs_optimization(&irs, sc); if (change) { m_ru->set_ir_list(irs); } return change; }