37 #define DEBUG_NAME "compiler2/DeadCodeEliminationPass"
41 "deadcodeeliminationpass","deadcodeeliminationpass",compiler2_stat)
43 "number of removed dead nodes",compiler2_deadcodeeliminationpass_stat)
45 "number of nodes not removed",compiler2_deadcodeeliminationpass_stat)
52 bool is_control_flow_inst(Instruction *inst) {
54 || inst->to_EndInst();
70 inWorkList[*
i] =
true;
83 while (!workList.empty()) {
86 inWorkList[
I] =
false;
91 && !is_control_flow_inst(I) && I->
rdep_size() == 0) {
96 deadInstructions.push_back(I);
98 for (Instruction::OperandListTy::const_iterator
102 if (Op && !visited[Op]) {
106 if (!inWorkList[Op]) {
107 workList.push_back(Op);
108 inWorkList[Op] =
true;
119 LOG(
"Dead: " << I <<
nl);
121 liveInstructions.push_back(I);
122 LOG(
"Live: " << I <<
nl);
126 STATISTICS(num_dead_nodes = deadInstructions.size());
127 STATISTICS(num_remaining_nodes = liveInstructions.size());
132 while (!deadInstructions.empty()) {
134 deadInstructions.pop_front();
#define STATISTICS(x)
Wrapper for statistics only code.
alloc::list< Instruction * >::type InstructionListTy
#define STAT_REGISTER_SUBGROUP(var, name, description, group)
Register a statistics group and add it to a group.
virtual bool has_side_effects() const
True the instruction has side effects.
void replace_instruction_list(InputIterator first, InputIterator last)
Replaces the instructions of the method, with the instructions in the given range [first...
SSAPrinterPass TODO: more info.
virtual PassUsage & get_PassUsage(PassUsage &PA) const
Set the requirements for the pass.
void add_schedule_before()
Schedule before PassName.
Stores the interdependencies of a pass.
#define STAT_REGISTER_GROUP_VAR(type, var, init, name, description, group)
Register an statistics variable and add it to a group.
virtual Instruction * to_Instruction()
InstructionListTy::const_iterator const_iterator
const_iterator end() const
const_op_iterator op_begin() const
#define LOG(STMT)
Analogous to DEBUG.
#define STAT_DECLARE_GROUP(var)
Declare an external group (or subgroup).
const_iterator begin() const
size_t user_size() const
Get the number of (unique) users.
virtual bool run(JITData &JD)
Run the Pass.
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
const_op_iterator op_end() const
void add_requires()
PassName is required.