From 63615ae50ee9866bafefb380a308aea533913fe1 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Fri, 20 Mar 2026 15:49:08 +0300 Subject: [PATCH] fixed function prototype --- src/Sapfor.cpp | 2 +- .../MoveOperators/move_operators.cpp | 45 +++++-------------- .../MoveOperators/move_operators.h | 2 +- src/Utils/version.h | 2 +- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 53e2b8c..f2a1876 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -943,7 +943,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne } } else if (curr_regime == MOVE_OPERATORS) - moveOperators(file, loopGraph, fullIR, countOfTransform); + moveOperators(fullIR, countOfTransform); else if (curr_regime == PRIVATE_REMOVING_ANALYSIS) { auto itFound = loopGraph.find(file->filename()); diff --git a/src/Transformations/MoveOperators/move_operators.cpp b/src/Transformations/MoveOperators/move_operators.cpp index 79de6cf..1c199ed 100644 --- a/src/Transformations/MoveOperators/move_operators.cpp +++ b/src/Transformations/MoveOperators/move_operators.cpp @@ -17,10 +17,6 @@ using namespace std; -// Provided by Sage runtime (declared in libSage++.h) -extern SgFile *current_file; - - set loop_tags = {FOR_NODE}; set control_tags = {IF_NODE, ELSEIF_NODE, DO_WHILE_NODE, WHILE_NODE, LOGIF_NODE}; set control_end_tags = {CONTROL_END}; @@ -551,38 +547,19 @@ static bool reorderOperatorsInBasicBlockUsingDeps(SAPFOR::BasicBlock* bb) return true; } -void moveOperators(SgFile *file, map>& loopGraph, - const map>& FullIR, - int& countOfTransform) { - // 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) +void moveOperators(const map>& FullIR, int& countOfTransform) { + const int funcNum = current_file->numberOfFunctions(); + for (int i = 0; i < funcNum; ++i) { - if (SgFile::switchToFile(fileName.c_str()) == -1) - continue; + SgStatement* st = current_file->functions(i); - SgFile* curFile = current_file; - if (!curFile) - continue; - - const int funcNum = curFile->numberOfFunctions(); - for (int i = 0; i < funcNum; ++i) + const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR); + for (auto* bb : loopBlocks) { - SgStatement* st = curFile->functions(i); - - const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR); - for (auto* bb : loopBlocks) - { - if (!bb) - continue; - if (reorderOperatorsInBasicBlockUsingDeps(bb)) - countOfTransform += 1; - } + if (!bb) + continue; + if (reorderOperatorsInBasicBlockUsingDeps(bb)) + countOfTransform += 1; } } - - if (!oldFileName.empty()) - SgFile::switchToFile(oldFileName.c_str()); -} \ No newline at end of file +} diff --git a/src/Transformations/MoveOperators/move_operators.h b/src/Transformations/MoveOperators/move_operators.h index 0bbbc9a..6b012cb 100644 --- a/src/Transformations/MoveOperators/move_operators.h +++ b/src/Transformations/MoveOperators/move_operators.h @@ -3,4 +3,4 @@ #include "../../GraphLoop/graph_loops.h" #include "../../CFGraph/CFGraph.h" -void moveOperators(SgFile *file, std::map>& loopGraph, const std::map>& FullIR, int& countOfTransform); +void moveOperators(const std::map>& FullIR, int& countOfTransform); diff --git a/src/Utils/version.h b/src/Utils/version.h index 65ec748..05ba3d0 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2471" +#define VERSION_SPF "2472"