dead_code_removing improvements #23
@@ -95,7 +95,7 @@ namespace SAPFOR
|
||||
}
|
||||
|
||||
return inserted;
|
||||
};
|
||||
}
|
||||
|
||||
bool BasicBlock::removeLive(SAPFOR::Argument* to_remove, bool in)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ namespace SAPFOR
|
||||
}
|
||||
|
||||
return removed;
|
||||
};
|
||||
}
|
||||
|
||||
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> BasicBlock::getLive(bool in) const {
|
||||
auto& current_set = in ? live_in : live_out;
|
||||
@@ -231,22 +231,22 @@ public:
|
||||
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getIn()
|
||||
{
|
||||
return getBlock()->getLiveOut();
|
||||
};
|
||||
}
|
||||
|
||||
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getOut()
|
||||
{
|
||||
return getBlock()->getLiveIn();
|
||||
};
|
||||
}
|
||||
|
||||
bool addIn(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
{
|
||||
return getBlock()->addLiveOut(data);
|
||||
};
|
||||
}
|
||||
|
||||
bool addOut(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
{
|
||||
return getBlock()->addLiveIn(data);
|
||||
};
|
||||
}
|
||||
|
||||
bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
inserted |= getBlock()->addLiveIn({ byArg });
|
||||
|
||||
return inserted;
|
||||
};
|
||||
}
|
||||
|
||||
LiveVarAnalysisNode(SAPFOR::BasicBlock* block, vector<SAPFOR::Argument*>& formal_parameters,
|
||||
vector<LiveDeadVarsForCall>& fcalls, const map<string, FuncInfo*>& funcByName)
|
||||
@@ -279,11 +279,11 @@ protected:
|
||||
|
||||
LiveVarAnalysisNode* createNode(SAPFOR::BasicBlock* block) override {
|
||||
return new LiveVarAnalysisNode(block, formal_parameters, fcalls, funcByName);
|
||||
};
|
||||
}
|
||||
public:
|
||||
LiveVarAnalysis(vector<SAPFOR::Argument*>& formal_parameters, vector<LiveDeadVarsForCall>& fcalls,
|
||||
const map<string, FuncInfo*>& funcByName) : formal_parameters(formal_parameters), fcalls(fcalls), funcByName(funcByName)
|
||||
{ };
|
||||
{ }
|
||||
};
|
||||
|
||||
void getUseDefForInstruction(SAPFOR::BasicBlock* block, SAPFOR::Instruction* instr,
|
||||
|
||||
@@ -37,7 +37,7 @@ void insertIfVar(IT begin, IT end, DEST& to) {
|
||||
for (auto it = begin; it != end; it++)
|
||||
if (*it && (*it)->getType() == SAPFOR::CFG_ARG_TYPE::VAR)
|
||||
to.insert(*it);
|
||||
};
|
||||
}
|
||||
|
||||
void getUseDefForInstruction(SAPFOR::BasicBlock* block, SAPFOR::Instruction* instr,
|
||||
std::set<SAPFOR::Argument*>& use, std::set<SAPFOR::Argument*>& def,
|
||||
|
||||
@@ -190,11 +190,11 @@ public:
|
||||
|
||||
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getIn() {
|
||||
return getBlock()->getLiveOut();
|
||||
};
|
||||
}
|
||||
|
||||
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getOut() {
|
||||
return getBlock()->getLiveIn();
|
||||
};
|
||||
}
|
||||
|
||||
bool addIn(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) {
|
||||
bool inserted = getBlock()->addLiveOut(data);
|
||||
@@ -205,11 +205,11 @@ public:
|
||||
inserted |= updateJumpStatus();
|
||||
|
||||
return inserted;
|
||||
};
|
||||
}
|
||||
|
||||
bool addOut(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) {
|
||||
return getBlock()->addLiveIn(data);
|
||||
};
|
||||
}
|
||||
|
||||
bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) {
|
||||
bool inserted = false;
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
}
|
||||
|
||||
return inserted;
|
||||
};
|
||||
}
|
||||
|
||||
DeadCodeAnalysisNode(SAPFOR::BasicBlock* block, vector<SAPFOR::Argument*>& formal_parameters) :
|
||||
formal_parameters(formal_parameters)
|
||||
@@ -295,7 +295,7 @@ public:
|
||||
getBlock()->addLiveIn({ { arg, { getBlock() } } });
|
||||
}
|
||||
|
||||
const vector<bool>& getResult() { return useful; };
|
||||
const vector<bool>& getResult() { return useful; }
|
||||
};
|
||||
|
||||
class DeadCodeAnalysis : public BackwardDataFlowAnalysis<DeadCodeAnalysisNode> {
|
||||
@@ -304,11 +304,11 @@ protected:
|
||||
|
||||
DeadCodeAnalysisNode* createNode(SAPFOR::BasicBlock* block) override {
|
||||
return new DeadCodeAnalysisNode(block, formal_parameters);
|
||||
};
|
||||
}
|
||||
public:
|
||||
DeadCodeAnalysis(vector<SAPFOR::Argument*>& formal_parameters) :
|
||||
formal_parameters(formal_parameters)
|
||||
{ };
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user