X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FUnreachableBlockElim.cpp;h=7824f92185755e9c7241b545c1d9b9e879cd4f4e;hb=138d5bf371fd69644ab781220f45d4308d3fc83d;hp=48d8ab1658da5912076b98fd6fed7d6a7cece3fb;hpb=80f6a507d4e11ba066ad0e53e12ad25ad8cf07ba;p=oota-llvm.git diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp index 48d8ab1658d..7824f921857 100644 --- a/lib/CodeGen/UnreachableBlockElim.cpp +++ b/lib/CodeGen/UnreachableBlockElim.cpp @@ -21,36 +21,34 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/Passes.h" -#include "llvm/Constant.h" -#include "llvm/Instructions.h" -#include "llvm/Function.h" -#include "llvm/Pass.h" -#include "llvm/Type.h" -#include "llvm/Analysis/Dominators.h" -#include "llvm/Analysis/ProfileInfo.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/Support/CFG.h" +#include "llvm/IR/CFG.h" +#include "llvm/IR/Constant.h" +#include "llvm/IR/Dominators.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/Type.h" +#include "llvm/Pass.h" #include "llvm/Target/TargetInstrInfo.h" -#include "llvm/ADT/DepthFirstIterator.h" -#include "llvm/ADT/SmallPtrSet.h" using namespace llvm; namespace { class UnreachableBlockElim : public FunctionPass { - virtual bool runOnFunction(Function &F); + bool runOnFunction(Function &F) override; public: static char ID; // Pass identification, replacement for typeid UnreachableBlockElim() : FunctionPass(ID) { initializeUnreachableBlockElimPass(*PassRegistry::getPassRegistry()); } - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addPreserved(); - AU.addPreserved(); + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.addPreserved(); } }; } @@ -66,9 +64,8 @@ bool UnreachableBlockElim::runOnFunction(Function &F) { SmallPtrSet Reachable; // Mark all reachable blocks. - for (df_ext_iterator > I = - df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable); I != E; ++I) - /* Mark all reachable blocks */; + for (BasicBlock *BB : depth_first_ext(&F, Reachable)) + (void)BB/* Mark all reachable blocks */; // Loop over all dead blocks, remembering them and deleting all instructions // in them. @@ -87,9 +84,7 @@ bool UnreachableBlockElim::runOnFunction(Function &F) { } // Actually remove the blocks now. - ProfileInfo *PI = getAnalysisIfAvailable(); for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) { - if (PI) PI->removeBlock(DeadBlocks[i]); DeadBlocks[i]->eraseFromParent(); } @@ -99,8 +94,8 @@ bool UnreachableBlockElim::runOnFunction(Function &F) { namespace { class UnreachableMachineBlockElim : public MachineFunctionPass { - virtual bool runOnMachineFunction(MachineFunction &F); - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + bool runOnMachineFunction(MachineFunction &F) override; + void getAnalysisUsage(AnalysisUsage &AU) const override; MachineModuleInfo *MMI; public: static char ID; // Pass identification, replacement for typeid @@ -129,10 +124,8 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { MachineLoopInfo *MLI = getAnalysisIfAvailable(); // Mark all reachable blocks. - for (df_ext_iterator > - I = df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable); - I != E; ++I) - /* Mark all reachable blocks */; + for (MachineBasicBlock *BB : depth_first_ext(&F, Reachable)) + (void)BB/* Mark all reachable blocks */; // Loop over all dead blocks, remembering them and deleting all instructions // in them. @@ -196,8 +189,11 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { temp->eraseFromParent(); ModifiedPHI = true; - if (Input != Output) - F.getRegInfo().replaceRegWith(Output, Input); + if (Input != Output) { + MachineRegisterInfo &MRI = F.getRegInfo(); + MRI.constrainRegClass(Input, MRI.getRegClass(Output)); + MRI.replaceRegWith(Output, Input); + } continue; }