Compare commits
3 Commits
02baed087f
...
492df9fe6c
| Author | SHA1 | Date | |
|---|---|---|---|
| 492df9fe6c | |||
| 1e5ae1ef80 | |||
| aa0a464ead |
@@ -1205,9 +1205,10 @@ static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLi
|
|||||||
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
||||||
{
|
{
|
||||||
SgExpression* funcArg = funcCallExp->arg(i);
|
SgExpression* funcArg = funcCallExp->arg(i);
|
||||||
if (funcInfo->funcParams.isArgOut(i)
|
if (funcArg->symbol() == nullptr || !isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
||||||
&& funcArg->symbol() != nullptr
|
continue;
|
||||||
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
|
||||||
|
if (funcInfo->funcParams.isArgOut(i) || funcArg->lhs() == nullptr)
|
||||||
{
|
{
|
||||||
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
||||||
fixedSubscripts.push_back(fixedVec);
|
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,
|
static void checkIndirectUsage(Context* ctx, FuncInfo* calledFunc, vector<Variable*> commonBlockGroupedVar,
|
||||||
set<string>& visitedFuncs, vector<vector<ArraySubscript>>& indirectUsageMasks)
|
set<string>& visitedFuncs, vector<vector<ArraySubscript>>& indirectUsageMasks)
|
||||||
{
|
{
|
||||||
|
if (calledFunc == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (visitedFuncs.find(calledFunc->funcName) != visitedFuncs.end())
|
if (visitedFuncs.find(calledFunc->funcName) != visitedFuncs.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1325,6 +1329,27 @@ static void checkIndirectUsage(Context* ctx, FuncInfo* calledFunc, vector<Variab
|
|||||||
checkIndirectUsage(ctx, subCalledFunc, commonBlockGroupedVar, visitedFuncs, indirectUsageMasks);
|
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
|
// 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
|
// (indirect usage is usage through common blocks) and writes messages about it
|
||||||
static vector<vector<ArraySubscript>> checkIndirectUsage(Context* ctx)
|
static vector<vector<ArraySubscript>> checkIndirectUsage(Context* ctx)
|
||||||
@@ -1348,6 +1373,9 @@ static vector<vector<ArraySubscript>> checkIndirectUsage(Context* ctx)
|
|||||||
FuncInfo* calledFunc = findFuncByName(procName, ctx->allFuncInfo);
|
FuncInfo* calledFunc = findFuncByName(procName, ctx->allFuncInfo);
|
||||||
checkIndirectUsage(ctx, calledFunc, commonBlockGroupedVar, visitedFunctions, indirectUsageMasks);
|
checkIndirectUsage(ctx, calledFunc, commonBlockGroupedVar, visitedFunctions, indirectUsageMasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
checkIndirectUsage(ctx, st->expr(i), commonBlockGroupedVar, visitedFunctions, indirectUsageMasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
return indirectUsageMasks;
|
return indirectUsageMasks;
|
||||||
@@ -1642,6 +1670,9 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
|||||||
for (auto& instruction : blockInstructionsVector)
|
for (auto& instruction : blockInstructionsVector)
|
||||||
{
|
{
|
||||||
SgStatement* stmt = instruction->getInstruction()->getOperator();
|
SgStatement* stmt = instruction->getInstruction()->getOperator();
|
||||||
|
if (stmt == useInsertedStmt.insertedStmt)
|
||||||
|
break;
|
||||||
|
|
||||||
if (stmt->variant() == ASSIGN_STAT
|
if (stmt->variant() == ASSIGN_STAT
|
||||||
&& stmt->expr(0)->symbol()->identifier() == defVarName
|
&& stmt->expr(0)->symbol()->identifier() == defVarName
|
||||||
&& !isVarChangedBetween(defVarName, stmt, useInsertedStmt.insertedStmt))
|
&& !isVarChangedBetween(defVarName, stmt, useInsertedStmt.insertedStmt))
|
||||||
|
|||||||
Reference in New Issue
Block a user