#include "llvm/iPHINode.h"
#include "llvm/Constant.h"
#include "llvm/Support/CFG.h"
-#include "Support/STLExtras.h"
+#include "Support/Debug.h"
#include "Support/DepthFirstIterator.h"
#include "Support/Statistic.h"
+#include "Support/STLExtras.h"
#include <algorithm>
namespace {
}
inline void markTerminatorLive(const BasicBlock *BB) {
- DEBUG(std::cerr << "Terminat Live: " << BB->getTerminator());
- markInstructionLive((Instruction*)BB->getTerminator());
+ DEBUG(std::cerr << "Terminator Live: " << BB->getTerminator());
+ markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
}
};
void ADCE::markBlockAlive(BasicBlock *BB) {
// Mark the basic block as being newly ALIVE... and mark all branches that
- // this block is control dependant on as being alive also...
+ // this block is control dependent on as being alive also...
//
PostDominanceFrontier &CDG = getAnalysis<PostDominanceFrontier>();
PostDominanceFrontier::const_iterator It = CDG.find(BB);
if (It != CDG.end()) {
- // Get the blocks that this node is control dependant on...
+ // Get the blocks that this node is control dependent on...
const PostDominanceFrontier::DomSetType &CDB = It->second;
for_each(CDB.begin(), CDB.end(), // Mark all their terminators as live
bind_obj(this, &ADCE::markTerminatorLive));
BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
- if (II->mayWriteToMemory() || II->getOpcode() == Instruction::Ret) {
+ if (II->mayWriteToMemory() || isa<ReturnInst>(II) || isa<UnwindInst>(II)){
markInstructionLive(II);
++II; // Increment the inst iterator if the inst wasn't deleted
} else if (isInstructionTriviallyDead(II)) {
// transformations safely.
//
PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
- if (DT[&Func->getEntryNode()] == 0) {
+ if (DT[&Func->getEntryBlock()] == 0) {
WorkList.clear();
return MadeChanges;
}
std::set<BasicBlock*> AliveBlocks;
// Process the work list of instructions that just became live... if they
- // became live, then that means that all of their operands are neccesary as
+ // became live, then that means that all of their operands are necessary as
// well... make them live as well.
//
while (!WorkList.empty()) {
} else {
PostDominatorTree::Node *NextNode = LastNode->getIDom();
- while (!AliveBlocks.count(NextNode->getNode())) {
+ while (!AliveBlocks.count(NextNode->getBlock())) {
LastNode = NextNode;
NextNode = NextNode->getIDom();
}
// Get the basic blocks that we need...
- BasicBlock *LastDead = LastNode->getNode();
- BasicBlock *NextAlive = NextNode->getNode();
+ BasicBlock *LastDead = LastNode->getBlock();
+ BasicBlock *NextAlive = NextNode->getBlock();
// Make the conditional branch now go to the next alive block...
TI->getSuccessor(i)->removePredecessor(BB);