- // If we found no dead instructions, we haven't changed the function...
- if (DeadInsts.empty()) return false;
-
- // Otherwise, loop over the program, removing and deleting the instructions...
- for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
- BasicBlock::InstListType &BBIL = (*I)->getInstList();
- for (BasicBlock::iterator BI = BBIL.begin(); BI != BBIL.end(); )
- if (DeadInsts.count(*BI)) { // Is this instruction dead?
- delete BBIL.remove(BI); // Yup, remove and delete inst
- } else { // This instruction is not dead
- ++BI; // Continue on to the next one...
- }