Deleted Added
full compact
DCE.cpp (208954) DCE.cpp (212904)
1//===- DCE.cpp - Code to perform dead code elimination --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 21 unchanged lines hidden (view full) ---

30STATISTIC(DCEEliminated, "Number of insts removed");
31
32namespace {
33 //===--------------------------------------------------------------------===//
34 // DeadInstElimination pass implementation
35 //
36 struct DeadInstElimination : public BasicBlockPass {
37 static char ID; // Pass identification, replacement for typeid
1//===- DCE.cpp - Code to perform dead code elimination --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 21 unchanged lines hidden (view full) ---

30STATISTIC(DCEEliminated, "Number of insts removed");
31
32namespace {
33 //===--------------------------------------------------------------------===//
34 // DeadInstElimination pass implementation
35 //
36 struct DeadInstElimination : public BasicBlockPass {
37 static char ID; // Pass identification, replacement for typeid
38 DeadInstElimination() : BasicBlockPass(&ID) {}
38 DeadInstElimination() : BasicBlockPass(ID) {}
39 virtual bool runOnBasicBlock(BasicBlock &BB) {
40 bool Changed = false;
41 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
42 Instruction *Inst = DI++;
43 if (isInstructionTriviallyDead(Inst)) {
44 Inst->eraseFromParent();
45 Changed = true;
46 ++DIEEliminated;

--- 4 unchanged lines hidden (view full) ---

51
52 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
53 AU.setPreservesCFG();
54 }
55 };
56}
57
58char DeadInstElimination::ID = 0;
39 virtual bool runOnBasicBlock(BasicBlock &BB) {
40 bool Changed = false;
41 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
42 Instruction *Inst = DI++;
43 if (isInstructionTriviallyDead(Inst)) {
44 Inst->eraseFromParent();
45 Changed = true;
46 ++DIEEliminated;

--- 4 unchanged lines hidden (view full) ---

51
52 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
53 AU.setPreservesCFG();
54 }
55 };
56}
57
58char DeadInstElimination::ID = 0;
59static RegisterPass<DeadInstElimination>
60X("die", "Dead Instruction Elimination");
59INITIALIZE_PASS(DeadInstElimination, "die",
60 "Dead Instruction Elimination", false, false);
61
62Pass *llvm::createDeadInstEliminationPass() {
63 return new DeadInstElimination();
64}
65
66
67namespace {
68 //===--------------------------------------------------------------------===//
69 // DeadCodeElimination pass implementation
70 //
71 struct DCE : public FunctionPass {
72 static char ID; // Pass identification, replacement for typeid
61
62Pass *llvm::createDeadInstEliminationPass() {
63 return new DeadInstElimination();
64}
65
66
67namespace {
68 //===--------------------------------------------------------------------===//
69 // DeadCodeElimination pass implementation
70 //
71 struct DCE : public FunctionPass {
72 static char ID; // Pass identification, replacement for typeid
73 DCE() : FunctionPass(&ID) {}
73 DCE() : FunctionPass(ID) {}
74
75 virtual bool runOnFunction(Function &F);
76
77 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
78 AU.setPreservesCFG();
79 }
80 };
81}
82
83char DCE::ID = 0;
74
75 virtual bool runOnFunction(Function &F);
76
77 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
78 AU.setPreservesCFG();
79 }
80 };
81}
82
83char DCE::ID = 0;
84static RegisterPass<DCE> Y("dce", "Dead Code Elimination");
84INITIALIZE_PASS(DCE, "dce", "Dead Code Elimination", false, false);
85
86bool DCE::runOnFunction(Function &F) {
87 // Start out with all of the instructions in the worklist...
88 std::vector<Instruction*> WorkList;
89 for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
90 WorkList.push_back(&*i);
91
92 // Loop over the worklist finding instructions that are dead. If they are

--- 40 unchanged lines hidden ---
85
86bool DCE::runOnFunction(Function &F) {
87 // Start out with all of the instructions in the worklist...
88 std::vector<Instruction*> WorkList;
89 for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
90 WorkList.push_back(&*i);
91
92 // Loop over the worklist finding instructions that are dead. If they are

--- 40 unchanged lines hidden ---