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;
100 deadInstructions.push_back(I);
102 for (Instruction::OperandListTy::const_iterator
106 if (Op && !visited[Op]) {
110 if (!inWorkList[Op]) {
111 workList.push_back(Op);
112 inWorkList[Op] =
true;
123 LOG(
"Dead: " << I <<
nl);
125 liveInstructions.push_back(I);
126 LOG(
"Live: " << I <<
nl);
130 STATISTICS(num_dead_nodes = deadInstructions.size());
131 STATISTICS(num_remaining_nodes = liveInstructions.size());
136 while (!deadInstructions.empty()) {
138 deadInstructions.pop_front();
alloc::unordered_map< Instruction *, bool >::type InstBoolMapTy
#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.
alloc::unordered_map< Instruction *, std::size_t >::type InstIntMapTy
virtual bool is_floating() const
True if the instruction has no fixed control dependencies.
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.
virtual SourceStateInst * to_SourceStateInst()
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
virtual AssumptionInst * to_AssumptionInst()
#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.
static Option< bool > enabled
virtual bool run(JITData &JD)
Run the Pass.
virtual ReplacementEntryInst * to_ReplacementEntryInst()
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
const_op_iterator op_end() const
void add_requires()
PassName is required.