44 #define DEBUG_NAME "compiler2/NullCheckEliminationPass"
69 for (
auto it =
M->
begin(); it !=
M->
end(); it++) {
101 while (!worklist.empty()) {
104 in_worklist[begin] =
false;
112 LOG2(
"Process " << begin <<
nl);
115 for (
auto inst_it = schedule->
inst_begin(begin);
116 inst_it != schedule->
inst_end(begin); inst_it++) {
121 LOG2(I <<
" is trivially non-null" <<
nl);
145 LOG2(
"Remove null-check on " << objectref <<
" by " << I <<
nl);
152 LOG2(
"Introduce null-check on " << objectref <<
" by " << I <<
nl);
171 bool reanalyze_successor = num_of_set_bits != new_num_of_set_bits;
172 if (reanalyze_successor && !in_worklist[succ]) {
174 in_worklist[succ] =
true;
180 #ifdef ENABLE_LOGGING
181 void NullCheckEliminationPass::print_final_results() {
182 for (
auto inst_it =
M->
begin(); inst_it !=
M->
end(); inst_it++) {
189 LOG(
"Null-check on " << objectref <<
" by " << I <<
" is redundant" <<
nl);
191 LOG(
"Null-check on " << objectref <<
" by " << I <<
" is not redundant" <<
nl);
204 #ifdef ENABLE_LOGGING
205 print_final_results();
virtual Instruction * to_Instruction()
Type::TypeID get_type() const
get the value type of the instruction
bool is_trivially_non_null(Value *objectref)
void set_needs_null_check(bool needs_null_check)
Control whether a null-check is needed to safeguard the dereference.
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
const_bb_iterator bb_end() const
This Instruction marks the start of a basic block.
This Instruction marks the end of a basic block.
alloc::unordered_map< Instruction *, int >::type bitpositions
Maps each object reference to a unique bitvector position.
virtual Instruction * get_objectref()=0
Get the corresponding object reference.
void prepare_bitvectors()
virtual LOADInst * to_LOADInst()
alloc::unordered_map< BeginInst *, boost::dynamic_bitset<> >::type non_null_references_at_entry
Holds for each BeginInst the local analysis state in the form of a bitvector.
void add_schedule_before()
Schedule before PassName.
const_inst_iterator inst_begin(const BeginInst *BI) const
virtual bool run(JITData &JD)
Run the Pass.
SuccessorListTy::const_iterator succ_end() const
Stores the interdependencies of a pass.
EndInst * get_EndInst() const
SuccessorListTy::const_iterator succ_begin() const
void map_referenes_to_bitpositions()
const_iterator end() const
const_op_iterator op_begin() const
virtual MULTIANEWARRAYInst * to_MULTIANEWARRAYInst()
void perform_null_check_elimination()
#define LOG(STMT)
Analogous to DEBUG.
virtual NEWInst * to_NEWInst()
const_iterator begin() const
bool get_needs_null_check() const
Whether a null-check is needed to safeguard the dereference.
std::queue< T, Container > type
unsigned get_index() const
The index of the argument is represented by this LOADInst.
Base type of instructions that dereference an object reference.
const_inst_iterator inst_end(const BeginInst *BI) const
SourceStateAttachmentPass.
virtual DereferenceInst * to_DereferenceInst()
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
virtual ANEWARRAYInst * to_ANEWARRAYInst()
virtual NEWARRAYInst * to_NEWARRAYInst()
alloc::unordered_map< BeginInst *, boost::dynamic_bitset<> >::type non_null_references_at_exit
const_op_iterator op_end() const
BeginInst * get_init_bb() const
void add_requires()
PassName is required.
A LOADInst represents an argument that is passed to the current method.
const_bb_iterator bb_begin() const
virtual PHIInst * to_PHIInst()
std::unordered_map< Key, T, Hash, KeyEqual, Allocator< std::pair< const Key, T > > > type