fixed function prototype

This commit is contained in:
ALEXks
2026-03-20 15:49:08 +03:00
committed by Egor Mayorov
parent 0d4d2b78d8
commit 88bac54901
4 changed files with 14 additions and 37 deletions

View File

@@ -943,7 +943,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
} }
} }
else if (curr_regime == MOVE_OPERATORS) else if (curr_regime == MOVE_OPERATORS)
moveOperators(file, loopGraph, fullIR, countOfTransform); moveOperators(fullIR, countOfTransform);
else if (curr_regime == PRIVATE_REMOVING_ANALYSIS) else if (curr_regime == PRIVATE_REMOVING_ANALYSIS)
{ {
auto itFound = loopGraph.find(file->filename()); auto itFound = loopGraph.find(file->filename());

View File

@@ -17,10 +17,6 @@
using namespace std; using namespace std;
// Provided by Sage runtime (declared in libSage++.h)
extern SgFile *current_file;
set<int> loop_tags = {FOR_NODE}; set<int> loop_tags = {FOR_NODE};
set<int> control_tags = {IF_NODE, ELSEIF_NODE, DO_WHILE_NODE, WHILE_NODE, LOGIF_NODE}; set<int> control_tags = {IF_NODE, ELSEIF_NODE, DO_WHILE_NODE, WHILE_NODE, LOGIF_NODE};
set<int> control_end_tags = {CONTROL_END}; set<int> control_end_tags = {CONTROL_END};
@@ -551,38 +547,19 @@ static bool reorderOperatorsInBasicBlockUsingDeps(SAPFOR::BasicBlock* bb)
return true; return true;
} }
void moveOperators(SgFile *file, map<string, vector<LoopGraph*>>& loopGraph, void moveOperators(const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR, int& countOfTransform) {
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR, const int funcNum = current_file->numberOfFunctions();
int& countOfTransform) { for (int i = 0; i < funcNum; ++i)
// Correct usage pattern in this project:
// save current file -> switch -> work on current_file -> restore.
const string oldFileName = (current_file ? current_file->filename() : "");
for (const auto& [fileName, _] : loopGraph)
{ {
if (SgFile::switchToFile(fileName.c_str()) == -1) SgStatement* st = current_file->functions(i);
continue;
SgFile* curFile = current_file; const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR);
if (!curFile) for (auto* bb : loopBlocks)
continue;
const int funcNum = curFile->numberOfFunctions();
for (int i = 0; i < funcNum; ++i)
{ {
SgStatement* st = curFile->functions(i); if (!bb)
continue;
const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR); if (reorderOperatorsInBasicBlockUsingDeps(bb))
for (auto* bb : loopBlocks) countOfTransform += 1;
{
if (!bb)
continue;
if (reorderOperatorsInBasicBlockUsingDeps(bb))
countOfTransform += 1;
}
} }
} }
if (!oldFileName.empty())
SgFile::switchToFile(oldFileName.c_str());
} }

View File

@@ -3,4 +3,4 @@
#include "../../GraphLoop/graph_loops.h" #include "../../GraphLoop/graph_loops.h"
#include "../../CFGraph/CFGraph.h" #include "../../CFGraph/CFGraph.h"
void moveOperators(SgFile *file, std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& FullIR, int& countOfTransform); void moveOperators(const std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& FullIR, int& countOfTransform);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2471" #define VERSION_SPF "2472"