void FunctionStaticSlicer::computeSC() { for (inst_iterator I = inst_begin(fun), E = inst_end(fun); I != E; I++) { const Instruction *i = &*I; SuccList succList = getSuccList(i); for (SuccList::const_iterator II = succList.begin(), EE = succList.end(); II != EE; II++) computeSCi(i, *II); } }
/* * Backward, Forward: get successors * */ bool FunctionStaticSlicer::computeRCi(InsInfo *insInfoi) { const Instruction *i = insInfoi->getIns(); bool changed = false; SuccList succList = getSuccList(i); SuccList::const_iterator I = succList.begin(), E = succList.end(); for (;I != E; I++) changed |= computeRCi(insInfoi, getInsInfo(*I)); return changed; }
static SuccList getSuccList(const Instruction *i) { SuccList succList; const BasicBlock *bb = i->getParent(); if (i != &bb->back()) { BasicBlock::const_iterator I(i); I++; succList.push_back(&*I); } else { for (succ_const_iterator I = succ_begin(bb), E = succ_end(bb); I != E; I++) succList.push_back(&(*I)->front()); } return succList; }
bool FunctionStaticSlicer::computeRCi(InsInfo *insInfoi) { const Instruction *i = insInfoi->getIns(); bool changed = false; #ifdef DEBUG_RC errs() << " " << __func__ << ": " << i->getOpcodeName(); if (i->hasName()) errs() << " (" << i->getName() << ")"; errs() << '\n'; errs() << " DUMP: "; i->print(errs()); errs() << '\n'; #endif SuccList succList = getSuccList(i); for (SuccList::const_iterator I = succList.begin(), E = succList.end(); I != E; I++) changed |= computeRCi(insInfoi, getInsInfo(*I)); return changed; }