private_removing: bug fixes
This commit is contained in:
@@ -885,18 +885,21 @@ static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLi
|
||||
{
|
||||
SgFunctionCallExp* funcCallExp = (SgFunctionCallExp*)exp;
|
||||
string funcName = funcCallExp->funName()->identifier();
|
||||
auto funcInfo = findFunc(ctx->loopStmt->fileName(), funcName, ctx->allFuncInfo);
|
||||
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
||||
FuncInfo* funcInfo = findFunc(ctx->loopStmt->fileName(), funcName, ctx->allFuncInfo);
|
||||
if (funcInfo != nullptr)
|
||||
{
|
||||
SgExpression* funcArg = funcCallExp->arg(i);
|
||||
if (funcInfo->funcParams.isArgOut(i)
|
||||
&& funcArg->symbol() != nullptr
|
||||
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
||||
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
||||
{
|
||||
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
||||
fixedSubscripts.push_back(fixedVec);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, fixedVec),
|
||||
funcName, ctx->loop->lineNum, stmtLineNum);
|
||||
SgExpression* funcArg = funcCallExp->arg(i);
|
||||
if (funcInfo->funcParams.isArgOut(i)
|
||||
&& funcArg->symbol() != nullptr
|
||||
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
||||
{
|
||||
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
||||
fixedSubscripts.push_back(fixedVec);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, fixedVec),
|
||||
funcName, ctx->loop->lineNum, stmtLineNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1231,32 +1234,40 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
{
|
||||
vector<DefUseStmtsPair> defUsePairs;
|
||||
|
||||
for (const InsertedStatement& stmt : insertedStmts)
|
||||
for (const InsertedStatement& useInsertedStmt : insertedStmts)
|
||||
{
|
||||
if (stmt.type != TypeOfInsertedStmt::USE)
|
||||
if (useInsertedStmt.type != TypeOfInsertedStmt::USE) // analysis for USE stmt
|
||||
continue;
|
||||
|
||||
int relLineNum = stmt.relatedToStmt->lineNumber();
|
||||
int useLineNum = useInsertedStmt.relatedToStmt->lineNumber();
|
||||
|
||||
// looking for reaching definitions for the current block:
|
||||
auto useInsAndBlock = getInstructionAndBlockByStatement(CFGraph, stmt.insertedStmt);
|
||||
auto useInsAndBlock = getInstructionAndBlockByStatement(CFGraph, useInsertedStmt.insertedStmt);
|
||||
auto useArg = useInsAndBlock.first->getArg1();
|
||||
const auto& RD_In = useInsAndBlock.second->getRD_In();
|
||||
|
||||
const auto& RD_forUseArg = RD_In.find(useArg);
|
||||
if (RD_forUseArg == RD_In.end()) // cannot find reaching definitions for argument
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
set<int> RD_defArgs = RD_forUseArg->second; // make copy
|
||||
|
||||
// delete recursive definition from RD def args:
|
||||
for (int defArgNum : RD_defArgs)
|
||||
{
|
||||
if (defArgNum == SAPFOR::CFG_VAL::UNINIT)
|
||||
continue;
|
||||
|
||||
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, defArgNum);
|
||||
if (defInsAndBlock.first == nullptr)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* defStmt = defInsAndBlock.first->getOperator();
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
||||
if (stmt.relatedToStmt == defInsertedStmt->relatedToStmt) // recursive definition
|
||||
if (useInsertedStmt.relatedToStmt == defInsertedStmt->relatedToStmt)
|
||||
{
|
||||
RD_defArgs.erase(defArgNum);
|
||||
break;
|
||||
@@ -1265,13 +1276,40 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
|
||||
if (RD_defArgs.size() == 0) // argument is not initialized
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RD_defArgs.find(SAPFOR::CFG_VAL::UNINIT) != RD_defArgs.end()) // argument is not initialized
|
||||
{
|
||||
bool uninitArgIsOk = false;
|
||||
if (RD_defArgs.size() == 2)
|
||||
{
|
||||
RD_defArgs.erase(SAPFOR::CFG_VAL::UNINIT);
|
||||
int defArgNum = *RD_defArgs.begin();
|
||||
|
||||
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, defArgNum);
|
||||
if (defInsAndBlock.first == nullptr)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defInsAndBlock.first->getOperator());
|
||||
if (defInsertedStmt->relatedToStmt->lineNumber() < useLineNum &&
|
||||
useInsAndBlock.second->getNumber() == defInsAndBlock.second->getNumber())
|
||||
{
|
||||
uninitArgIsOk = true; // argument isn't really uninitialized
|
||||
}
|
||||
}
|
||||
|
||||
if (!uninitArgIsOk)
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (RD_defArgs.size() > 1) // more than one reaching definition
|
||||
{
|
||||
addMessageMoreThanOneRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageMoreThanOneRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1282,19 +1320,19 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
||||
if (defInsertedStmt == insertedStmts.end())
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
//don't substitute def stmt into use, if def is recursive
|
||||
if (defInsertedStmt->isRecursive)
|
||||
{
|
||||
addMessageRecursiveDependency(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageRecursiveDependency(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
SgAssignStmt* def = (SgAssignStmt*)defInsertedStmt->relatedToStmt;
|
||||
SgAssignStmt* use = (SgAssignStmt*)stmt.relatedToStmt;
|
||||
SgAssignStmt* use = (SgAssignStmt*)useInsertedStmt.relatedToStmt;
|
||||
defUsePairs.push_back(make_pair(def, use));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user