improved CFG settings
This commit is contained in:
@@ -105,23 +105,48 @@ namespace SAPFOR
|
|||||||
|
|
||||||
struct CFG_Settings
|
struct CFG_Settings
|
||||||
{
|
{
|
||||||
|
enum setting { CFG_atLeastOneIterInLoop = 1,
|
||||||
|
CFG_withRD = 2,
|
||||||
|
CFG_withRegisters = 3,
|
||||||
|
CFG_withSPF = 4,
|
||||||
|
CFG_withDVM = 5,
|
||||||
|
CFG_withCallsInBlocks = 6,
|
||||||
|
CFG_withCallFrom = 7,
|
||||||
|
CFG_withDominators = 8 };
|
||||||
|
|
||||||
bool atLeastOneIterInLoop = false;
|
bool atLeastOneIterInLoop = false;
|
||||||
bool withRD = true;
|
bool withRD = false;
|
||||||
bool withRegisters = false;
|
bool withRegisters = false;
|
||||||
bool withSPF = false;
|
bool withSPF = false;
|
||||||
bool withDVM = false;
|
bool withDVM = false;
|
||||||
bool withCallsInBlocks = false; // separate each F_CALL to own BasicBlock
|
bool withCallsInBlocks = false; // separate each F_CALL to own BasicBlock
|
||||||
bool withCallFrom = true;
|
bool withCallFrom = false;
|
||||||
bool withDominators = true;
|
bool withDominators = false;
|
||||||
|
|
||||||
explicit CFG_Settings(int) { }
|
explicit CFG_Settings(const std::set<setting> &settings = { CFG_withRD, CFG_withCallFrom, CFG_withDominators })
|
||||||
|
{
|
||||||
explicit CFG_Settings(bool atLeastOneIterInLoop = false, bool withRD = true, bool withRegisters = false,
|
for (auto& set : settings)
|
||||||
bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false,
|
{
|
||||||
bool withCallFrom = true, bool withDominators = true) :
|
if (set == CFG_atLeastOneIterInLoop)
|
||||||
atLeastOneIterInLoop(atLeastOneIterInLoop), withRD(withRD), withRegisters(withRegisters), withDVM(withDVM), withSPF(withSPF),
|
atLeastOneIterInLoop = true;
|
||||||
withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom), withDominators(withDominators)
|
else if (set == CFG_withRD)
|
||||||
{ }
|
withRD = true;
|
||||||
|
else if (set == CFG_withRegisters)
|
||||||
|
withRegisters = true;
|
||||||
|
else if (set == CFG_withSPF)
|
||||||
|
withSPF = true;
|
||||||
|
else if (set == CFG_withDVM)
|
||||||
|
withDVM = true;
|
||||||
|
else if (set == CFG_withCallsInBlocks)
|
||||||
|
withCallsInBlocks = true;
|
||||||
|
else if (set == CFG_withCallFrom)
|
||||||
|
withCallFrom = true;
|
||||||
|
else if (set == CFG_withDominators)
|
||||||
|
withDominators = true;
|
||||||
|
else
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ using std::string;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
|
using SAPFOR::CFG_Settings;
|
||||||
|
|
||||||
extern int debSh;
|
extern int debSh;
|
||||||
|
|
||||||
@@ -1672,9 +1673,11 @@ void GroupShadow(const map<string, vector<FuncInfo*>>& allFuncs,
|
|||||||
|
|
||||||
SgStatement* func = currF->funcPointer->GetOriginal();
|
SgStatement* func = currF->funcPointer->GetOriginal();
|
||||||
|
|
||||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, true, false), commonBlocks, allFuncs);
|
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop, CFG_Settings::CFG_withSPF, CFG_Settings::CFG_withCallsInBlocks });
|
||||||
|
auto cfg = buildCFGforCurrentFunc(func, settings, commonBlocks, allFuncs);
|
||||||
if (cfg.size() != 1)
|
if (cfg.size() != 1)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto& blocks = cfg.begin()->second;
|
auto& blocks = cfg.begin()->second;
|
||||||
|
|
||||||
//create reaching blocks
|
//create reaching blocks
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ using std::set;
|
|||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::tuple;
|
using std::tuple;
|
||||||
|
using SAPFOR::CFG_Settings;
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -507,7 +508,8 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
|||||||
if (currF == NULL)
|
if (currF == NULL)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, false, true), commonBlocks, allFuncInfo);
|
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop, CFG_Settings::CFG_withSPF, CFG_Settings::CFG_withDominators });
|
||||||
|
auto cfg = buildCFGforCurrentFunc(func, settings, commonBlocks, allFuncInfo);
|
||||||
//TODO IP analysis
|
//TODO IP analysis
|
||||||
|
|
||||||
unsigned countOfAccess = 0;
|
unsigned countOfAccess = 0;
|
||||||
|
|||||||
@@ -1893,7 +1893,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
findParameters(parametersOfProject, fullIR, declaredArrays);
|
findParameters(parametersOfProject, fullIR, declaredArrays);
|
||||||
else if (curr_regime == BUILD_IR)
|
else if (curr_regime == BUILD_IR)
|
||||||
{
|
{
|
||||||
auto CFG_forFile = buildCFG(commonBlocks, allFuncInfo_IR, SAPFOR::CFG_Settings(0));
|
auto CFG_forFile = buildCFG(commonBlocks, allFuncInfo_IR, SAPFOR::CFG_Settings());
|
||||||
for (auto& byFunc : CFG_forFile)
|
for (auto& byFunc : CFG_forFile)
|
||||||
fullIR[byFunc.first].insert(fullIR[byFunc.first].end(), byFunc.second.begin(), byFunc.second.end());
|
fullIR[byFunc.first].insert(fullIR[byFunc.first].end(), byFunc.second.begin(), byFunc.second.end());
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using std::map;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
using SAPFOR::CFG_Settings;
|
||||||
|
|
||||||
using std::remove_if;
|
using std::remove_if;
|
||||||
|
|
||||||
@@ -424,7 +425,8 @@ int removeDeadCode(SgStatement* func,
|
|||||||
if (intervalDelEnd->lineNumber() < prog->lineNumber() || intervalDelEnd->lineNumber() > prog->lastNodeOfStmt()->lineNumber())
|
if (intervalDelEnd->lineNumber() < prog->lineNumber() || intervalDelEnd->lineNumber() > prog->lastNodeOfStmt()->lineNumber())
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, false, false, false, false), commonBlocks, allFuncs);
|
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop });
|
||||||
|
auto cfg = buildCFGforCurrentFunc(func, settings, commonBlocks, allFuncs);
|
||||||
|
|
||||||
if(cfg.size() != 1)
|
if(cfg.size() != 1)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using std::pair;
|
|||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
using std::stack;
|
using std::stack;
|
||||||
|
using SAPFOR::CFG_Settings;
|
||||||
|
|
||||||
#define PRINT_SPLITTED_FRAGMENTS 0
|
#define PRINT_SPLITTED_FRAGMENTS 0
|
||||||
|
|
||||||
@@ -315,7 +316,7 @@ static map<SgStatement*, pair<set<SgStatement*>, set<SgStatement*>>>
|
|||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
map<SAPFOR::Argument*, set<int>> outForCurr;
|
map<SAPFOR::Argument*, set<int>> outForCurr;
|
||||||
buildGenKillForCFG(itCFG->second, funcByName, outForFunc, gen, kill, &genForIR, &killForIR, notInitedGlobals, SAPFOR::CFG_Settings(0));
|
buildGenKillForCFG(itCFG->second, funcByName, outForFunc, gen, kill, &genForIR, &killForIR, notInitedGlobals, SAPFOR::CFG_Settings());
|
||||||
|
|
||||||
if (outForFunc.count(byFunc))
|
if (outForFunc.count(byFunc))
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
@@ -1051,7 +1052,8 @@ int splitLoops(SgFile *file, vector<LoopGraph*> &loopGraphs, vector<Messages> &m
|
|||||||
checkNull(listExp, convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(listExp, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
int deep = listExp->length();
|
int deep = listExp->length();
|
||||||
|
|
||||||
currIR = buildCFGforCurrentFunc(loop->loop, SAPFOR::CFG_Settings(true, true), commonBlocks, allFuncInfo);
|
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop, CFG_Settings::CFG_withRD, CFG_Settings::CFG_withCallFrom, CFG_Settings::CFG_withDominators });
|
||||||
|
currIR = buildCFGforCurrentFunc(loop->loop, settings, commonBlocks, allFuncInfo);
|
||||||
totalErr = splitLoop(loop, messages, deep, depInfoForLoopGraph);
|
totalErr = splitLoop(loop, messages, deep, depInfoForLoopGraph);
|
||||||
|
|
||||||
if (totalErr > 0)
|
if (totalErr > 0)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using std::set;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
using SAPFOR::CFG_Settings;
|
||||||
|
|
||||||
using CFG_Type = map<FuncInfo*, vector<SAPFOR::BasicBlock*>>;
|
using CFG_Type = map<FuncInfo*, vector<SAPFOR::BasicBlock*>>;
|
||||||
using UsersDirectives = map<pair<string, int>, set<SgStatement*>>;
|
using UsersDirectives = map<pair<string, int>, set<SgStatement*>>;
|
||||||
@@ -2207,8 +2208,8 @@ static void removePrivateAnalyze(Context *ctx)
|
|||||||
makeDeclaration(ctx->loopStmt, vector<SgSymbol*> {receiverVar}, nullptr)
|
makeDeclaration(ctx->loopStmt, vector<SgSymbol*> {receiverVar}, nullptr)
|
||||||
));
|
));
|
||||||
|
|
||||||
CFG_Type CFG_ForFunc = buildCFGforCurrentFunc(ctx->loopStmt,
|
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop, CFG_Settings::CFG_withRD, CFG_Settings::CFG_withCallFrom, CFG_Settings::CFG_withDominators });
|
||||||
SAPFOR::CFG_Settings(true, true),
|
CFG_Type CFG_ForFunc = buildCFGforCurrentFunc(ctx->loopStmt, settings,
|
||||||
ctx->commonBlocks, ctx->allFuncInfo);
|
ctx->commonBlocks, ctx->allFuncInfo);
|
||||||
if (CFG_ForFunc.empty())
|
if (CFG_ForFunc.empty())
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2461"
|
#define VERSION_SPF "2462"
|
||||||
|
|||||||
Reference in New Issue
Block a user