Compare commits
10 Commits
c2c111586c
...
b40e969d02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b40e969d02 | ||
| d062e52dd6 | |||
| 392ad97738 | |||
|
|
a2e44a9548 | ||
| b8b2c6baa7 | |||
| 083a1f5189 | |||
|
|
e9774ebc46 | ||
| f1f69ef658 | |||
| 17de9e271a | |||
| 01016a7b9f |
@@ -6,6 +6,8 @@
|
||||
#include "../CFGraph.h"
|
||||
#include "../IR.h"
|
||||
|
||||
enum class DATA_FLOW_UPD_STATUS { NO_CHANGE = 0, PROPAGATED, GENERATED };
|
||||
|
||||
template <class DataType>
|
||||
class DataFlowAnalysisNode {
|
||||
static const int CNT_NOTINIT = 0;
|
||||
@@ -13,7 +15,6 @@ class DataFlowAnalysisNode {
|
||||
int in_cnt = CNT_NOTINIT, out_cnt = CNT_NOTINIT;
|
||||
|
||||
std::set<int> rollback;
|
||||
std::set<int> ignore_rollback;
|
||||
|
||||
std::set<DataFlowAnalysisNode<DataType>*> prev_blocks;
|
||||
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
virtual bool addOut(const DataType& data) = 0;
|
||||
|
||||
virtual bool updateState() { return false; }
|
||||
virtual bool forwardData(const DataType& data) = 0;
|
||||
virtual DATA_FLOW_UPD_STATUS forwardData(const DataType& data) = 0;
|
||||
|
||||
bool newerThan(const DataFlowAnalysisNode<DataType>* block) const { return out_cnt > block->in_cnt; }
|
||||
|
||||
@@ -42,7 +43,6 @@ public:
|
||||
static int getStartCounter() { return CNT_NOTINIT; }
|
||||
|
||||
std::set<int>& getRollback() { return rollback; }
|
||||
std::set<int>& getIgnoreRollback() { return ignore_rollback; }
|
||||
|
||||
std::set<DataFlowAnalysisNode<DataType>*>& getPrevBlocks() { return prev_blocks; }
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ template <class DataType>
|
||||
DataFlowAnalysisNode<DataType>::DataFlowAnalysisNode()
|
||||
{
|
||||
getRollback() = {};
|
||||
getIgnoreRollback() = {};
|
||||
prev_blocks = {};
|
||||
}
|
||||
|
||||
@@ -33,18 +32,21 @@ void DataFlowAnalysisNode<DataType>::doStep()
|
||||
{
|
||||
if (in_cnt < next->out_cnt)
|
||||
{
|
||||
if (next->out_cnt > in_max_cnt)
|
||||
in_max_cnt = next->out_cnt;
|
||||
|
||||
const auto& byOut = next->getOut();
|
||||
bool inserted = addIn( byOut);
|
||||
|
||||
if (inserted)
|
||||
{
|
||||
if (next->out_cnt > in_max_cnt)
|
||||
in_max_cnt = next->out_cnt;
|
||||
|
||||
inserted = forwardData(byOut);
|
||||
auto status = forwardData(byOut);
|
||||
inserted = status != DATA_FLOW_UPD_STATUS::NO_CHANGE;
|
||||
|
||||
if (inserted && next->out_cnt > out_max_cnt)
|
||||
out_max_cnt = next->out_cnt;
|
||||
|
||||
uniq_change |= status == DATA_FLOW_UPD_STATUS::GENERATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,12 +83,10 @@ void DataFlowAnalysis<NodeType>::analyze()
|
||||
const auto& jumps = curr_bb->getRollback();
|
||||
if (jumps.size() != 0)
|
||||
{
|
||||
auto& ignored_jumps = curr_bb->getIgnoreRollback();
|
||||
|
||||
bool jump = false;
|
||||
for (const auto& jump_to : jumps)
|
||||
{
|
||||
if (ignored_jumps.insert(jump_to).second && curr_bb->newerThan(nodes[jump_to]))
|
||||
if (curr_bb->newerThan(nodes[jump_to]))
|
||||
{
|
||||
jump = true;
|
||||
curr = jump_to;
|
||||
@@ -94,9 +94,7 @@ void DataFlowAnalysis<NodeType>::analyze()
|
||||
}
|
||||
}
|
||||
|
||||
if (!jump)
|
||||
curr_bb->getIgnoreRollback().clear();
|
||||
else
|
||||
if (jump)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1235,8 +1235,9 @@ bool isArgReaches(int decl_instr, SAPFOR::BasicBlock* decl_bb,
|
||||
if (RDs_for_arg.size() == 1)
|
||||
{
|
||||
const int rd = *RDs_for_arg.begin();
|
||||
if (rd >= decl_bb->getInstructions().front()->getNumber() && rd < decl_instr)
|
||||
return true;
|
||||
if (rd >= decl_bb->getInstructions().front()->getNumber() &&
|
||||
rd <= decl_bb->getInstructions().back()->getNumber())
|
||||
return rd < decl_instr;
|
||||
}
|
||||
|
||||
auto arg_in_from_decl_it = decl_bb->getRD_In().find(arg);
|
||||
|
||||
@@ -107,23 +107,21 @@ namespace SAPFOR
|
||||
|
||||
removed |= (current_set.erase(to_remove) != 0);
|
||||
|
||||
if (!removed)
|
||||
auto it = live_inout.find(to_remove);
|
||||
|
||||
if (it != live_inout.end())
|
||||
{
|
||||
auto it = live_inout.find(to_remove);
|
||||
|
||||
if (it != live_inout.end())
|
||||
auto& dest = opposite_set[to_remove];
|
||||
for (SAPFOR::BasicBlock* bb : it->second)
|
||||
{
|
||||
auto& dest = opposite_set[to_remove];
|
||||
for (SAPFOR::BasicBlock* bb : it->second)
|
||||
{
|
||||
auto find_bb_from_dest = std::lower_bound(dest.begin(), dest.end(), bb);
|
||||
auto find_bb_from_dest = std::lower_bound(dest.begin(), dest.end(), bb);
|
||||
|
||||
if (find_bb_from_dest == dest.end() || *find_bb_from_dest != bb)
|
||||
dest.insert(find_bb_from_dest, bb);
|
||||
}
|
||||
|
||||
removed = true;
|
||||
if (find_bb_from_dest == dest.end() || *find_bb_from_dest != bb)
|
||||
dest.insert(find_bb_from_dest, bb);
|
||||
}
|
||||
|
||||
live_inout.erase(to_remove);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
return removed;
|
||||
@@ -253,7 +251,7 @@ public:
|
||||
return getBlock()->addLiveIn(data);
|
||||
}
|
||||
|
||||
bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
DATA_FLOW_UPD_STATUS forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
{
|
||||
bool inserted = false;
|
||||
|
||||
@@ -261,7 +259,7 @@ public:
|
||||
if (live.find(byArg.first) == live.end() && dead.find(byArg.first) == dead.end())
|
||||
inserted |= getBlock()->addLiveIn({ byArg });
|
||||
|
||||
return inserted;
|
||||
return inserted ? DATA_FLOW_UPD_STATUS::PROPAGATED : DATA_FLOW_UPD_STATUS::NO_CHANGE;
|
||||
}
|
||||
|
||||
LiveVarAnalysisNode(SAPFOR::BasicBlock* block, vector<SAPFOR::Argument*>& formal_parameters,
|
||||
@@ -740,7 +738,7 @@ void runLiveVariableAnalysis(const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>&
|
||||
if (exit->addIn(converted))
|
||||
{
|
||||
exit->setInCnt(max_cnt);
|
||||
if (exit->forwardData(converted))
|
||||
if (exit->forwardData(converted) != DATA_FLOW_UPD_STATUS::NO_CHANGE)
|
||||
exit->setOutCnt(max_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,10 +793,7 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
||||
continue;
|
||||
|
||||
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
||||
{
|
||||
st = st->lastNodeOfStmt();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (st->variant() == ASSIGN_STAT)
|
||||
{
|
||||
@@ -961,6 +958,15 @@ static void fillCommons(FuncInfo *currInfo, const map<string, vector<SgExpressio
|
||||
}
|
||||
}
|
||||
|
||||
static void printActiveLines(const set<SgStatement*>& activeOps)
|
||||
{
|
||||
set<int> lines;
|
||||
for (auto& st : activeOps)
|
||||
lines.insert(st->lineNumber());
|
||||
for (auto& line : lines)
|
||||
printf("%d\n", line);
|
||||
}
|
||||
|
||||
static FuncInfo* createNewFuction(const string& funcName, SgStatement *st, SgStatement* entry,
|
||||
vector<Messages>& messagesForFile,
|
||||
const map<string, vector<SgExpression*>>& commonBlocks,
|
||||
@@ -993,7 +999,6 @@ static FuncInfo* createNewFuction(const string& funcName, SgStatement *st, SgSta
|
||||
}
|
||||
|
||||
currInfo->funcParams.completeParams();
|
||||
|
||||
return currInfo;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1094,6 @@ static FuncInfo* analyzeFunction(const string& funcName, const string& containsP
|
||||
isSgExecutableStatement(st) &&
|
||||
activeOps.find(st) == activeOps.end())
|
||||
{
|
||||
st = st->lastNodeOfStmt();
|
||||
st = st->lexNext();
|
||||
continue;
|
||||
}
|
||||
@@ -1197,7 +1201,7 @@ static FuncInfo* analyzeFunction(const string& funcName, const string& containsP
|
||||
return procInfo;
|
||||
}
|
||||
|
||||
static set<SgStatement*> fillActiveOperators(const vector<SAPFOR::BasicBlock*>& blocks)
|
||||
static set<SgStatement*> fillActiveOperators(SgStatement* func, const vector<SAPFOR::BasicBlock*>& blocks)
|
||||
{
|
||||
if (blocks.size() == 0)
|
||||
return set<SgStatement*>();
|
||||
@@ -1233,6 +1237,28 @@ static set<SgStatement*> fillActiveOperators(const vector<SAPFOR::BasicBlock*>&
|
||||
}
|
||||
}
|
||||
|
||||
//complete blocked statements
|
||||
for (auto st = func->lexNext(); st != func->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
break;
|
||||
|
||||
if (st->variant() == SWITCH_NODE)
|
||||
{
|
||||
auto select = isSgSwitchStmt(st);
|
||||
int numOfCases = select->numberOfCaseOptions();
|
||||
for (int z = 0; z < numOfCases; ++z)
|
||||
{
|
||||
auto caseOp = isSgCaseOptionStmt(select->caseOption(z));
|
||||
if (active.count(caseOp))
|
||||
{
|
||||
active.insert(st);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
@@ -1319,7 +1345,7 @@ void functionAnalyzer(SgFile *file, map<string, vector<FuncInfo*>> &allFuncInfo,
|
||||
if (tmpInfoInIR.count(function) == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
activeOps = fillActiveOperators(fullIR[tmpInfoInIR[function]]);
|
||||
activeOps = fillActiveOperators((isEntry ? function->controlParent() : function), fullIR[tmpInfoInIR[function]]);
|
||||
activeOps.insert(function);
|
||||
if (isEntry)
|
||||
activeOps.insert(function->controlParent());
|
||||
|
||||
@@ -16,6 +16,75 @@ enum class typeEvery { TIME, ITER };
|
||||
|
||||
static const vector<string> iosNames = { "spf_close_all", "spf_open_all", "spf_inc_num_part" };
|
||||
|
||||
static SgStatement* replaceForWithWhile(SgStatement* forSt)
|
||||
{
|
||||
checkNull(forSt, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto forStat = isSgForStmt(forSt);
|
||||
checkNull(forStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto start = forStat->start();
|
||||
auto end = forStat->end();
|
||||
auto step = forStat->step();
|
||||
if (step == NULL)
|
||||
step = new SgValueExp(1);
|
||||
|
||||
auto stepCalc = CalculateInteger(step->copyPtr());
|
||||
|
||||
auto doName = forStat->doName();
|
||||
|
||||
checkNull(start, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
checkNull(end, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* insert = forSt->lexPrev();
|
||||
SgStatement* doWhile = NULL;
|
||||
|
||||
if (stepCalc->isInteger())
|
||||
{
|
||||
const int stepValue = stepCalc->valueInteger();
|
||||
auto cond = (stepValue > 0) ? (*new SgVarRefExp(doName) < end->copy()) : (*new SgVarRefExp(doName) > end->copy());
|
||||
auto cond2 = (stepValue > 0) ? (*new SgVarRefExp(doName) > end->copy()) : (*new SgVarRefExp(doName) < end->copy());
|
||||
SgLogIfStmt* logIf = new SgLogIfStmt(cond2, *new SgStatement(EXIT_STMT));
|
||||
|
||||
doWhile = new SgWhileStmt(&cond, NULL);
|
||||
insert->insertStmtAfter(*doWhile, *insert->controlParent());
|
||||
auto insertTo = doWhile->lastNodeOfStmt();
|
||||
|
||||
SgStatement* last = forSt->lastNodeOfStmt();
|
||||
while (forSt->lexNext() != last)
|
||||
{
|
||||
auto body = forSt->lexNext();
|
||||
insertTo->insertStmtBefore(*body->extractStmt(), *doWhile);
|
||||
}
|
||||
|
||||
doWhile->insertStmtBefore(*new SgAssignStmt(*new SgVarRefExp(doName), start->copy() - step->copy()), *insert->controlParent());
|
||||
|
||||
doWhile->insertStmtAfter(*logIf, *doWhile);
|
||||
doWhile->insertStmtAfter(*new SgAssignStmt(*new SgVarRefExp(doName), (*new SgVarRefExp(doName) + *step)), *doWhile);
|
||||
|
||||
doWhile->addComment(forSt->comments());
|
||||
forSt->extractStmt();
|
||||
}
|
||||
else
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
return doWhile;
|
||||
}
|
||||
|
||||
static void checkForToReplace(SgStatement* gotoBlock, SgStatement* goPoint)
|
||||
{
|
||||
//return;
|
||||
auto cp = gotoBlock->controlParent();
|
||||
while (goPoint->controlParent() != cp)
|
||||
{
|
||||
auto top = goPoint->controlParent();
|
||||
if (top->variant() == FOR_NODE)
|
||||
goPoint = replaceForWithWhile(top);
|
||||
else
|
||||
goPoint = top;
|
||||
}
|
||||
}
|
||||
|
||||
static void createModule(SgStatement*& module, const string& name, bool withFile = true)
|
||||
{
|
||||
if (module == NULL)
|
||||
@@ -757,8 +826,11 @@ static void insertStmtToModule(const map<string, SgStatement*>& moduleStmts, con
|
||||
SgStatement* borderStmt = new SgStatement(VAR_DECL);
|
||||
proc_moduleF->insertStmtAfter(*borderStmt, *proc_moduleF);
|
||||
|
||||
for (const auto& [varName, varStmt] : moduleStmts)
|
||||
for (auto& stat : moduleStmts)
|
||||
{
|
||||
const auto& varName = stat.first;
|
||||
SgStatement* varStmt = stat.second;
|
||||
|
||||
string varNameNoPref = varName;
|
||||
varNameNoPref.erase(0, prefixLen + 1);
|
||||
|
||||
@@ -950,7 +1022,7 @@ static SgStatement* createSaveBlock(const vector<SgSymbol*>& loadS, FuncInfo*& f
|
||||
const vector<string>& moduleNames, const int unitNum, const vector<vector<string>>& chainLocalVarNoParams,
|
||||
const vector<string>& chainLabel)
|
||||
{
|
||||
SgStatement* storeBlock = new SgIfStmt(IF_NODE);
|
||||
SgStatement* storeBlock = new SgIfStmt((SgExpression*)NULL);
|
||||
|
||||
vector<SgExpression*> listSpec;
|
||||
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("form"), *new SgValueExp("unformatted")));
|
||||
@@ -1116,6 +1188,8 @@ static void processAllCalls(SgStatement* firstExec, const string funcToName, con
|
||||
|
||||
gotoBlock->insertStmtBefore(*gotoNextPU, *gotoBlock);
|
||||
saveVarToModule(localVarNoParams, execStmt, funcFromName.c_str(), procLabelSymb, labNum);
|
||||
|
||||
checkForToReplace(gotoBlock, execStmt);
|
||||
}
|
||||
|
||||
execStmt = execStmt->lexNext();
|
||||
@@ -1225,7 +1299,7 @@ static void processFunctionCallChain(SgStatement* func, const vector<FuncInfo*>&
|
||||
|
||||
|
||||
SgStatement* gotoBlock = new SgStatement(IF_NODE);
|
||||
gotoBlock->addComment("! goto next program unit\n");
|
||||
gotoBlock->addComment("! GOTO NEXT PROGRAM UNIT\n");
|
||||
gotoBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(1));
|
||||
loadBlock->insertStmtAfter(*gotoBlock, *loadBlock->controlParent());
|
||||
|
||||
@@ -1565,6 +1639,8 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
|
||||
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(0));
|
||||
gotoBlock->insertStmtAfter(*init, *gotoBlock);
|
||||
loadBlock->insertStmtAfter(*gotoBlock, *loadBlock->controlParent());
|
||||
|
||||
checkForToReplace(gotoBlock, point);
|
||||
}
|
||||
|
||||
processModules(file, allFuncInfo);
|
||||
|
||||
@@ -235,6 +235,15 @@ public:
|
||||
if (!useful_block)
|
||||
updated |= updateNextNotEmpty();
|
||||
|
||||
if (!useful_block)
|
||||
{
|
||||
if (next_notempty_in != next_notempty_out)
|
||||
{
|
||||
updated = true;
|
||||
next_notempty_out = next_notempty_in;
|
||||
}
|
||||
}
|
||||
|
||||
updated |= updateJumpStatus();
|
||||
|
||||
if(updated)
|
||||
@@ -243,9 +252,10 @@ public:
|
||||
return updated;
|
||||
}
|
||||
|
||||
bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
DATA_FLOW_UPD_STATUS forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
|
||||
{
|
||||
bool inserted = false;
|
||||
bool inserted_prop = false, inserted_gen = false;
|
||||
|
||||
SAPFOR::BasicBlock* bb = getBlock();
|
||||
|
||||
set<SAPFOR::Argument*> use, def;
|
||||
@@ -271,7 +281,7 @@ public:
|
||||
if (data_it == data.end())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
inserted |= bb->addLiveIn({ *data_it });
|
||||
inserted_prop |= bb->addLiveIn({ *data_it });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -285,7 +295,7 @@ public:
|
||||
bb->removeLiveIn(arg);
|
||||
}
|
||||
if(!skip)
|
||||
inserted |= bb->addLiveIn({ { arg, { bb } } });
|
||||
inserted_gen |= bb->addLiveIn({ { arg, { bb } } });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,23 +308,19 @@ public:
|
||||
{
|
||||
useful_block = true;
|
||||
|
||||
inserted = true;
|
||||
inserted_gen = true;
|
||||
next_notempty_out = { this };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!useful_block)
|
||||
{
|
||||
if (next_notempty_in != next_notempty_out)
|
||||
{
|
||||
inserted = true;
|
||||
next_notempty_out = next_notempty_in;
|
||||
}
|
||||
}
|
||||
if(inserted_gen)
|
||||
return DATA_FLOW_UPD_STATUS::GENERATED;
|
||||
else if(inserted_prop)
|
||||
return DATA_FLOW_UPD_STATUS::PROPAGATED;
|
||||
|
||||
return inserted;
|
||||
return DATA_FLOW_UPD_STATUS::NO_CHANGE;
|
||||
}
|
||||
|
||||
DeadCodeAnalysisNode(SAPFOR::BasicBlock* block,
|
||||
|
||||
@@ -188,6 +188,17 @@ static void removeExternalStat(SgStatement* func, const set<string>& addedInterf
|
||||
rem->deleteStmt();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static vector<FuncInfo*> sortByName(const T &funcs)
|
||||
{
|
||||
vector<FuncInfo*> funcList;
|
||||
for (auto& elem : funcs)
|
||||
funcList.push_back(elem);
|
||||
|
||||
std::sort(funcList.begin(), funcList.end(), [](FuncInfo* a, FuncInfo* b) { return a->funcName > b->funcName; });
|
||||
return funcList;
|
||||
}
|
||||
|
||||
void createInterfacesForAssumedSize(const map<string, vector<FuncInfo*>>& allFuncInfo)
|
||||
{
|
||||
set<FuncInfo*> hasAssumedSizeArrays;
|
||||
@@ -251,14 +262,14 @@ void createInterfacesForAssumedSize(const map<string, vector<FuncInfo*>>& allFun
|
||||
if (SgFile::switchToFile(funcByFile.first) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& func : funcByFile.second)
|
||||
for (auto& func : sortByName(funcByFile.second))
|
||||
{
|
||||
SgProgHedrStmt* prog = isSgProgHedrStmt(func->funcPointer->GetOriginal());
|
||||
if (prog == NULL)
|
||||
continue;
|
||||
|
||||
set<string> addedInterfaceFor;
|
||||
for (auto& elem : func->callsFromV)
|
||||
for (auto& elem : sortByName(func->callsFromV))
|
||||
{
|
||||
auto it = hasAssumedSizeArrays.find(elem);
|
||||
if (it != hasAssumedSizeArrays.end())
|
||||
@@ -423,25 +434,20 @@ static void insertIntents(set<string>& identificators, SgStatement* header, cons
|
||||
}
|
||||
|
||||
SgExpression* attr = new SgExpression(intentVariant);
|
||||
SgExpression* args = NULL;
|
||||
vector<SgExpression*> args;
|
||||
for (auto& par : identificators)
|
||||
{
|
||||
if (parSym.count(par) == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
auto s = parSym.at(par);
|
||||
|
||||
SgExprListExp* tempArgs = new SgExprListExp();
|
||||
SgVarRefExp* tempPar = new SgVarRefExp(s);
|
||||
tempArgs->setLhs(tempPar);
|
||||
if (args)
|
||||
tempArgs->setRhs(args);
|
||||
args = tempArgs;
|
||||
auto s = parSym.at(par);
|
||||
args.push_back(new SgVarRefExp(s));
|
||||
s->setAttribute(s->attributes() | intentBit);
|
||||
}
|
||||
|
||||
if (args)
|
||||
if (args.size())
|
||||
{
|
||||
SgIntentStmt* intent = new SgIntentStmt(*args, *attr);
|
||||
SgIntentStmt* intent = new SgIntentStmt(*makeExprList(args), *attr);
|
||||
lastDecl->insertStmtAfter(*intent, (header == lastDecl) ? *header : *lastDecl->controlParent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,15 @@ static void FindAllVars(SgExpression* expr, set<SgSymbol*>& allVars, set<SgSymbo
|
||||
if (var == VAR_REF || var == ARRAY_REF || var == FUNC_CALL)
|
||||
{
|
||||
auto s = expr->symbol();
|
||||
if ((s->attributes() & EXTERNAL_BIT))
|
||||
if (var == FUNC_CALL /*(s->attributes() & EXTERNAL_BIT)*/)
|
||||
{
|
||||
if (var == FUNC_CALL && !IS_BY_USE(s) && s->scope() == scope)
|
||||
if (!IS_BY_USE(s) /* && s->scope() == scope*/)
|
||||
allVars.insert(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IS_BY_USE(s) && s->scope() == scope)
|
||||
{
|
||||
allVars.insert(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (var == CONST_REF)
|
||||
@@ -210,6 +208,15 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
|
||||
functionSymbs.insert(hedr->resultName()->identifier());
|
||||
}
|
||||
|
||||
auto prog = isSgProgHedrStmt(function);
|
||||
if (prog)
|
||||
{
|
||||
for (int z = 0; z < prog->numberOfInternalSubroutinesDefined(); ++z)
|
||||
functionSymbs.insert(prog->internalSubroutine(z)->symbol()->identifier());
|
||||
for (int z = 0; z < prog->numberOfInternalFunctionsDefined(); ++z)
|
||||
functionSymbs.insert(prog->internalFunction(z)->symbol()->identifier());
|
||||
}
|
||||
|
||||
for (auto st = function->lexNext(); st != endOfFunc && st->variant() != CONTAINS_STMT; st = st->lexNext())
|
||||
{
|
||||
if (skip.count(st->variant()))
|
||||
@@ -247,7 +254,6 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
|
||||
}
|
||||
|
||||
//add parameters
|
||||
auto prog = isSgProgHedrStmt(function);
|
||||
if (prog)
|
||||
{
|
||||
for (int z = 0; z < prog->numberOfParameters(); ++z)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2341"
|
||||
#define VERSION_SPF "2346"
|
||||
|
||||
Reference in New Issue
Block a user