3 Commits

4 changed files with 12 additions and 13 deletions

View File

@@ -74,12 +74,6 @@ namespace SAPFOR
const std::vector<BasicBlock*>& getPrev() const { return prev; } const std::vector<BasicBlock*>& getPrev() const { return prev; }
BasicBlock* getDom() const BasicBlock* getDom() const
{ {
if (!directDominator)
{
__spf_print(1, "%s\n", "the dominator tree was built with an error or was not built at all");
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
}
return directDominator; return directDominator;
} }

View File

@@ -64,6 +64,8 @@ namespace SAPFOR {
int w = vertex[i]; int w = vertex[i];
for (BasicBlock* v : vertices[w]->getPrev()) { for (BasicBlock* v : vertices[w]->getPrev()) {
if (dfs_num[v] == -1)
continue;
int u = Eval(dfs_num[v]); int u = Eval(dfs_num[v]);
if (semi[u] < semi[w]) if (semi[u] < semi[w])

View File

@@ -131,9 +131,9 @@ static void lookup_for_vars(set<tuple<SgStatement*, string, MODE>>& where_to_add
if (worklist.count(result_arg)) if (worklist.count(result_arg))
{ {
worklist.erase(result_arg);
processArgument(worklist, arg1, cur_instr, first_instr); processArgument(worklist, arg1, cur_instr, first_instr);
processArgument(worklist, arg2, cur_instr, first_instr); processArgument(worklist, arg2, cur_instr, first_instr);
worklist.erase(result_arg);
} }
if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1))
@@ -159,6 +159,8 @@ static void lookup_for_vars(set<tuple<SgStatement*, string, MODE>>& where_to_add
const auto& RD = bblock->getRD_In(); const auto& RD = bblock->getRD_In();
map<SAPFOR::BasicBlock*, SAPFOR::Instruction*> group_by_block; map<SAPFOR::BasicBlock*, SAPFOR::Instruction*> group_by_block;
set<SAPFOR::Argument*> to_erase;
for (auto& arg : worklist) for (auto& arg : worklist)
{ {
if (RD.count(arg)) if (RD.count(arg))
@@ -175,7 +177,7 @@ static void lookup_for_vars(set<tuple<SgStatement*, string, MODE>>& where_to_add
__spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); __spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename);
auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE);
where_to_add.insert(toAdd); where_to_add.insert(toAdd);
worklist.erase(arg); to_erase.insert(arg);
} }
else else
{ {
@@ -186,6 +188,8 @@ static void lookup_for_vars(set<tuple<SgStatement*, string, MODE>>& where_to_add
} }
} }
} }
for (const auto& arg : to_erase)
worklist.erase(arg);
while (bblock && group_by_block.find(bblock) == group_by_block.end()) while (bblock && group_by_block.find(bblock) == group_by_block.end())
bblock = bblock->getDom(); bblock = bblock->getDom();
@@ -408,9 +412,8 @@ void findParameters(ResultSet& foundParameters,
SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str());
SgVarRefExp* var = new SgVarRefExp(var_symb); SgVarRefExp* var = new SgVarRefExp(var_symb);
SgValueExp* zero = new SgValueExp(1337);
SgExprListExp* ex = new SgExprListExp(); SgExprListExp* ex = new SgExprListExp();
auto assgn_op = new SgExpression(ASSGN_OP, var, zero); auto assgn_op = new SgExpression(ASSGN_OP, var, NULL);
ex->setLhs(assgn_op); ex->setLhs(assgn_op);
SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex); SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex);

View File

@@ -5,7 +5,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "..\GraphCall\graph_calls.h" #include "../GraphCall/graph_calls.h"
using ResultSet = std::set<std::tuple<std::string, int, std::string>>; using ResultSet = std::set<std::tuple<std::string, int, std::string>>;