improved CFG settings

This commit is contained in:
ALEXks
2026-02-14 09:59:20 +03:00
parent bc9c7cba5c
commit 6091fa474d
8 changed files with 59 additions and 24 deletions

View File

@@ -12,6 +12,7 @@ using std::map;
using std::string;
using std::vector;
using std::set;
using SAPFOR::CFG_Settings;
using std::remove_if;
@@ -424,7 +425,8 @@ int removeDeadCode(SgStatement* func,
if (intervalDelEnd->lineNumber() < prog->lineNumber() || intervalDelEnd->lineNumber() > prog->lastNodeOfStmt()->lineNumber())
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)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);

View File

@@ -19,6 +19,7 @@ using std::pair;
using std::make_pair;
using std::wstring;
using std::stack;
using SAPFOR::CFG_Settings;
#define PRINT_SPLITTED_FRAGMENTS 0
@@ -315,7 +316,7 @@ static map<SgStatement*, pair<set<SgStatement*>, set<SgStatement*>>>
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
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))
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__);
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);
if (totalErr > 0)

View File

@@ -13,6 +13,7 @@ using std::set;
using std::string;
using std::vector;
using std::wstring;
using SAPFOR::CFG_Settings;
using CFG_Type = map<FuncInfo*, vector<SAPFOR::BasicBlock*>>;
using UsersDirectives = map<pair<string, int>, set<SgStatement*>>;
@@ -2207,8 +2208,8 @@ static void removePrivateAnalyze(Context *ctx)
makeDeclaration(ctx->loopStmt, vector<SgSymbol*> {receiverVar}, nullptr)
));
CFG_Type CFG_ForFunc = buildCFGforCurrentFunc(ctx->loopStmt,
SAPFOR::CFG_Settings(true, true),
const auto settings = CFG_Settings({ CFG_Settings::CFG_atLeastOneIterInLoop, CFG_Settings::CFG_withRD, CFG_Settings::CFG_withCallFrom, CFG_Settings::CFG_withDominators });
CFG_Type CFG_ForFunc = buildCFGforCurrentFunc(ctx->loopStmt, settings,
ctx->commonBlocks, ctx->allFuncInfo);
if (CFG_ForFunc.empty())
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);