private_removing #39

Merged
Alexander_KS merged 2 commits from private_removing into master 2024-04-09 07:37:05 +00:00

View File

@@ -1205,9 +1205,10 @@ static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLi
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
{
SgExpression* funcArg = funcCallExp->arg(i);
if (funcInfo->funcParams.isArgOut(i)
&& funcArg->symbol() != nullptr
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
if (funcArg->symbol() == nullptr || !isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
continue;
if (funcInfo->funcParams.isArgOut(i) || funcArg->lhs() == nullptr)
{
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
fixedSubscripts.push_back(fixedVec);
@@ -1295,6 +1296,9 @@ static vector<Variable*> getCommonBlockGroupedVar(FuncInfo* curFunc, SgSymbol* v
static void checkIndirectUsage(Context* ctx, FuncInfo* calledFunc, vector<Variable*> commonBlockGroupedVar,
set<string>& visitedFuncs, vector<vector<ArraySubscript>>& indirectUsageMasks)
{
if (calledFunc == nullptr)
return;
if (visitedFuncs.find(calledFunc->funcName) != visitedFuncs.end())
return;
@@ -1325,6 +1329,27 @@ static void checkIndirectUsage(Context* ctx, FuncInfo* calledFunc, vector<Variab
checkIndirectUsage(ctx, subCalledFunc, commonBlockGroupedVar, visitedFuncs, indirectUsageMasks);
}
// checkIndirectUsage returns masks of array indirect usage in any function call in exp
// (indirect usage is usage through common blocks) and writes messages about it
static void checkIndirectUsage(Context* ctx, SgExpression* exp, vector<Variable*> commonBlockGroupedVar,
set<string>& visitedFuncs, vector<vector<ArraySubscript>>& indirectUsageMasks)
{
if (exp == nullptr)
return;
if (exp->variant() == FUNC_CALL)
{
SgFunctionCallExp* funcCallExp = (SgFunctionCallExp*)exp;
string funcName = funcCallExp->funName()->identifier();
FuncInfo* funcInfo = findFuncByName(funcName, ctx->allFuncInfo);
if (funcInfo != nullptr)
checkIndirectUsage(ctx, funcInfo, commonBlockGroupedVar, visitedFuncs, indirectUsageMasks);
}
checkIndirectUsage(ctx, exp->lhs(), commonBlockGroupedVar, visitedFuncs, indirectUsageMasks);
checkIndirectUsage(ctx, exp->rhs(), commonBlockGroupedVar, visitedFuncs, indirectUsageMasks);
}
// checkIndirectUsage returns masks of array indirect usage in any function call in loop
// (indirect usage is usage through common blocks) and writes messages about it
static vector<vector<ArraySubscript>> checkIndirectUsage(Context* ctx)
@@ -1348,6 +1373,9 @@ static vector<vector<ArraySubscript>> checkIndirectUsage(Context* ctx)
FuncInfo* calledFunc = findFuncByName(procName, ctx->allFuncInfo);
checkIndirectUsage(ctx, calledFunc, commonBlockGroupedVar, visitedFunctions, indirectUsageMasks);
}
for (int i = 0; i < 3; ++i)
checkIndirectUsage(ctx, st->expr(i), commonBlockGroupedVar, visitedFunctions, indirectUsageMasks);
}
return indirectUsageMasks;
@@ -1642,6 +1670,9 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
for (auto& instruction : blockInstructionsVector)
{
SgStatement* stmt = instruction->getInstruction()->getOperator();
if (stmt == useInsertedStmt.insertedStmt)
break;
if (stmt->variant() == ASSIGN_STAT
&& stmt->expr(0)->symbol()->identifier() == defVarName
&& !isVarChangedBetween(defVarName, stmt, useInsertedStmt.insertedStmt))