projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Extended syntax of vector version of getelementptr instruction.
[oota-llvm.git]
/
lib
/
CodeGen
/
UnreachableBlockElim.cpp
diff --git
a/lib/CodeGen/UnreachableBlockElim.cpp
b/lib/CodeGen/UnreachableBlockElim.cpp
index 0e8a8a7e08f7af9af14de70d0cdc47d787eb821d..d393e103104df5c29fcbf601a41bb71129f3b57a 100644
(file)
--- a/
lib/CodeGen/UnreachableBlockElim.cpp
+++ b/
lib/CodeGen/UnreachableBlockElim.cpp
@@
-21,32
+21,34
@@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/Passes.h"
//===----------------------------------------------------------------------===//
#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/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/MachineDominators.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.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/Target/TargetInstrInfo.h"
-#include "llvm/ADT/DepthFirstIterator.h"
-#include "llvm/ADT/SmallPtrSet.h"
using namespace llvm;
namespace {
class UnreachableBlockElim : public FunctionPass {
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
public:
static char ID; // Pass identification, replacement for typeid
- UnreachableBlockElim() : FunctionPass(ID) {}
+ UnreachableBlockElim() : FunctionPass(ID) {
+ initializeUnreachableBlockElimPass(*PassRegistry::getPassRegistry());
+ }
- v
irtual void getAnalysisUsage(AnalysisUsage &AU) const
{
- AU.addPreserved<
ProfileInfo
>();
+ v
oid getAnalysisUsage(AnalysisUsage &AU) const override
{
+ AU.addPreserved<
DominatorTreeWrapperPass
>();
}
};
}
}
};
}
@@
-62,9
+64,8
@@
bool UnreachableBlockElim::runOnFunction(Function &F) {
SmallPtrSet<BasicBlock*, 8> Reachable;
// Mark all reachable blocks.
SmallPtrSet<BasicBlock*, 8> Reachable;
// Mark all reachable blocks.
- for (df_ext_iterator<Function*, SmallPtrSet<BasicBlock*, 8> > 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.
// Loop over all dead blocks, remembering them and deleting all instructions
// in them.
@@
-83,20
+84,18
@@
bool UnreachableBlockElim::runOnFunction(Function &F) {
}
// Actually remove the blocks now.
}
// Actually remove the blocks now.
- ProfileInfo *PI = getAnalysisIfAvailable<ProfileInfo>();
for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
- if (PI) PI->removeBlock(DeadBlocks[i]);
DeadBlocks[i]->eraseFromParent();
}
DeadBlocks[i]->eraseFromParent();
}
- return
DeadBlocks.size
();
+ return
!DeadBlocks.empty
();
}
namespace {
class UnreachableMachineBlockElim : public MachineFunctionPass {
}
namespace {
class UnreachableMachineBlockElim : public MachineFunctionPass {
-
virtual bool runOnMachineFunction(MachineFunction &F)
;
- v
irtual void getAnalysisUsage(AnalysisUsage &AU) const
;
+
bool runOnMachineFunction(MachineFunction &F) override
;
+ v
oid getAnalysisUsage(AnalysisUsage &AU) const override
;
MachineModuleInfo *MMI;
public:
static char ID; // Pass identification, replacement for typeid
MachineModuleInfo *MMI;
public:
static char ID; // Pass identification, replacement for typeid
@@
-125,10
+124,8
@@
bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
// Mark all reachable blocks.
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
// Mark all reachable blocks.
- for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> >
- 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.
// Loop over all dead blocks, remembering them and deleting all instructions
// in them.
@@
-192,8
+189,11
@@
bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
temp->eraseFromParent();
ModifiedPHI = true;
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;
}
continue;
}
@@
-204,5
+204,5
@@
bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
F.RenumberBlocks();
F.RenumberBlocks();
- return (
DeadBlocks.size
() || ModifiedPHI);
+ return (
!DeadBlocks.empty
() || ModifiedPHI);
}
}