From 4eb057731f6419da9cec067573e92989437a7b7f Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Wed, 5 Mar 2025 16:34:32 +0300 Subject: [PATCH 01/32] trivial case for local variables only --- src/ProjectParameters/projectParameters.cpp | 203 ++++++++++++++++-- src/ProjectParameters/projectParameters.h | 23 +- src/Sapfor.cpp | 7 +- src/SapforData.h | 2 +- .../parameter/dynamic_array_maximum.f90 | 52 +++++ 5 files changed, 271 insertions(+), 16 deletions(-) create mode 100644 tests/sapfor/parameter/dynamic_array_maximum.f90 diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index fd395dc..7ac33d0 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -1,8 +1,6 @@ -#include "../Utils/leak_detector.h" - +#include #include #include -#include #include #include #include @@ -11,23 +9,202 @@ #include #include +#include "../Utils/SgUtils.h" +#include "../CFGraph/CFGraph.h" +#include "CFGraph/IR.h" +#include "Distribution/Array.h" #include "dvm.h" #include "../Utils/errors.h" -#include "../Utils/SgUtils.h" #include "../GraphCall/graph_calls.h" #include "../GraphCall/graph_calls_func.h" +#include "libSage++.h" #include "projectParameters.h" using namespace std; -map< pair, set> - findParameters(const map> &defUseByFunctions, - const map &commonBlocks, - const map> &allFuncInfo) +template +static void processArgument(set& worklist, SAPFOR::Argument* arg, Iterator instr, Iterator first_instr) { + if (arg == NULL) + return; + if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) + extract_vars_from_reg(worklist, arg, instr, first_instr); + else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR && arg->getMemType() == SAPFOR::CFG_MEM_TYPE::LOCAL_) + { + std::cout << "worklist add: " << arg->getValue() << std::endl; //DEBUG PRINT + worklist.insert(arg); + } +} + +template +void extract_vars_from_reg(set& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr) { + for (; instr >= first_instr; instr--) { + if ((*instr)->getInstruction()->getResult() == reg) + { + processArgument(worklist, (*instr)->getInstruction()->getArg1(), instr, first_instr); + processArgument(worklist, (*instr)->getInstruction()->getArg2(), instr, first_instr); + return; + } + } +} + +static void lookup_for_vars(ResultSet& result_set, + set& worklist, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + const std::map>& fullIR) { - map< pair, set> foundParameters; - - - return foundParameters; -} \ No newline at end of file + std::cout << "Lookup in bblock no." << bblock->getNumber() << std::endl; //DEBUG PRINT + + auto first_instr = bblock->getInstructions().begin(); + auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { + return i->getInstruction() == instr; + }); + + for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) + { + auto instr = (*cur_instr)->getInstruction(); + auto result_arg = instr->getResult(); + auto arg1 = instr->getArg1(); + auto arg2 = instr->getArg2(); + + if (worklist.count(result_arg)) + { + processArgument(worklist, arg1, cur_instr, first_instr); + processArgument(worklist, arg2, cur_instr, first_instr); + std::cout << "worklist erase: " << result_arg->getValue() << std::endl; //DEBUG PRINT + worklist.erase(result_arg); + } + if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) + { + // skip to F_CALL + auto f_call_instr = cur_instr; + while ((*f_call_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL) + f_call_instr++; + + if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ") + { + auto filename = (*f_call_instr)->getInstruction()->getOperator()->fileName(); + auto line = (*f_call_instr)->getInstruction()->getOperator()->lineNumber(); + __spf_print(1,"Please specify value of variable %s on line %d of file %s", arg1->getValue().c_str(), line, filename); + result_set.insert(make_tuple(filename, line, arg1->getValue())); + + std::cout << "worklist erase: " << arg1->getValue() << std::endl; //DEBUG PRINT + worklist.erase(arg1); + } else + { + //check if variable is modified in called function + } + } + } + + + const auto& RD = bblock->getRD_In(); + map group_by_block; + for (auto& arg : worklist) + { + if (RD.count(arg)) + { + if (RD.at(arg).size() == 0) + __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); + else if (RD.at(arg).size() > 1) + __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible", arg->getValue().c_str()); + else + { + for (const auto& instr_num : RD.at(arg)) + { + auto [instr, bblock] = getInstructionAndBlockByNumber(fullIR, instr_num); + if (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) + group_by_block[bblock] = instr; + } + } + } + } + + for (const auto& [bblock, instr] : group_by_block) + { + lookup_for_vars(result_set, worklist, instr, bblock, fullIR); + } +} + +static void handle_single_allocate(ResultSet& result_set, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + const std::map>& fullIR) +{ + auto first_instr = bblock->getInstructions().begin(); + auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { + return i->getInstruction() == instr; + }); + auto alloc_instr = cur_instr; + + // skip to F_CALL _ALLOC n + while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL || + (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") + { + alloc_instr++; + } + + auto arrays_num = stoi((*alloc_instr)->getInstruction()->getArg2()->getValue()); + std::cout << "arrays_num: " << arrays_num << std::endl; //DEBUG PRINT + + set worklist; + for (int i = 0; i < arrays_num; i++) + { + auto param_instr = --alloc_instr; + auto param_reg = (*param_instr)->getInstruction()->getArg1(); + + while ((*param_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::LOAD || + (*param_instr)->getInstruction()->getResult() != param_reg) + { + param_instr--; + } + + auto dimensions_num = stoi((*param_instr)->getInstruction()->getArg2()->getValue()); + + for (int j = 0; j < dimensions_num; j++) + { + auto ref_instr = --param_instr; + + auto arg = (*ref_instr)->getInstruction()->getArg1(); + if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) + { + extract_vars_from_reg(worklist, arg, ref_instr, first_instr); + } + else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR && arg->getMemType() == SAPFOR::CFG_MEM_TYPE::LOCAL_) + { + std::cout << "worklist add: " << arg->getValue() << std::endl; //DEBUG PRINT + worklist.insert(arg); + } + } + } + lookup_for_vars(result_set,worklist, instr, bblock, fullIR); +} + +ResultSet +findParameters(const std::map>& fullIR, + const std::map, std::pair>& declaredArrays) +{ + ResultSet foundParameters; + std::set alloc_statements; + for (const auto& elem : declaredArrays) + { + const auto& array = elem.second.first; + assert(array->GetLocation().first == Distribution::arrayLocation::l_LOCAL); // v0.1 + + SgSymbol* arraySymb = array->GetDeclSymbol()->GetOriginal(); + SgStatement* decl = declaratedInStmt(arraySymb); + for (auto &stmt : getAttributes(decl, set{ ALLOCATE_STMT })) + { + alloc_statements.insert(stmt); + } + } + + for (const auto& alloc_statement : alloc_statements) + { + auto [instr, bblock] = getInstructionAndBlockByStatement(fullIR, alloc_statement); + ResultSet result_set; + handle_single_allocate(result_set, instr, bblock, fullIR); + } + return foundParameters; +} diff --git a/src/ProjectParameters/projectParameters.h b/src/ProjectParameters/projectParameters.h index 5a240b0..25e32e4 100644 --- a/src/ProjectParameters/projectParameters.h +++ b/src/ProjectParameters/projectParameters.h @@ -1,3 +1,24 @@ #pragma once -std::map< std::pair, std::set> findParameters(const std::map> &defUseByFunctions, const std::map &commonBlocks, const std::map> &allFuncInfo); \ No newline at end of file +#include +#include +#include + +using ResultSet = std::set>; + +template +void extract_vars_from_reg(std::set& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr); + + +template +static void processArgument(std::set& worklist, SAPFOR::Argument* arg, Iterator instr, Iterator first_instr); + +static void lookup_for_vars(ResultSet& result_set, + std::set& worklist, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + const std::map>& fullIR); + +ResultSet +findParameters(const std::map>& fullIR, + const std::map, std::pair>& declaredArrays); diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 5f5f93d..cbdaa32 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -1894,7 +1894,11 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == RENAME_SYMBOLS) runRenameSymbols(&project, commonBlocks); else if (curr_regime == FIND_PARAMETERS) - parametersOfProject = findParameters(defUseByFunctions, commonBlocks, allFuncInfo); + { + performRDSubst(fullIR, commonBlocks, &project); + parametersOfProject = findParameters(fullIR, declaredArrays); + performRDSubst(fullIR, commonBlocks, &project); + } else if (curr_regime == BUILD_IR) { auto CFG_forFile = buildCFG(commonBlocks, allFuncInfo_IR, SAPFOR::CFG_Settings(0)); @@ -2373,6 +2377,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case FIX_COMMON_BLOCKS: case TEST_PASS: case SET_IMPLICIT_NONE: + case FIND_PARAMETERS: runAnalysis(*project, curr_regime, false); case SUBST_EXPR_RD_AND_UNPARSE: case SUBST_EXPR_AND_UNPARSE: diff --git a/src/SapforData.h b/src/SapforData.h index cfd4f42..54ebc85 100644 --- a/src/SapforData.h +++ b/src/SapforData.h @@ -168,7 +168,7 @@ std::map filesInfo; // information about open,close,write and re // //for FIND_PARAMETERS -std::map< std::pair, std::set> parametersOfProject; // [file, line] -> set[vars] +std::set> parametersOfProject; // [file, line, varname] // //for GET_MIN_MAX_BLOCK_DIST diff --git a/tests/sapfor/parameter/dynamic_array_maximum.f90 b/tests/sapfor/parameter/dynamic_array_maximum.f90 new file mode 100644 index 0000000..f49e5e3 --- /dev/null +++ b/tests/sapfor/parameter/dynamic_array_maximum.f90 @@ -0,0 +1,52 @@ +program dynamic_array_maximum_3d + implicit none + integer :: n1, n2, n3, n4 , k, i, j, l, a + integer :: sum3 + real :: max_element + real, allocatable :: array(:,:,:), array2(:,:,:), array3(:,:,:) + + write(*, *) "Enter 3 integers" + read(*, *) n, m, k + m = 100 + + if (1 .eq. 1) then + a = 3 + else if (2 .eq. 1) then + a = 4 + endif + + m = m + 1 + k = m * 1000 + n * 10 + + allocate(array(n, m + n, k + m + n), & + &array2(k, m + n, k), & + &array3(k, m, k + n)) + + call random_seed() + do i = 1, n1 + do j = 1, m * n1 + do l = 1, k * m * n1 + call random_number(array(i,j,l)) + array(i,j,l) = int(array(i,j,l) * 100) + end do + end do + end do + + max_element = array(1,1,1) + do i = 1, n1 + do j = 1, m + do l = 1, k + max_element = MAX(array(i,j,l), max_element) + end do + end do + end do + deallocate(array, array2, array3) + write(*, *) max_element +end program dynamic_array_maximum_3d + +! function sum3(x, y, z) +! implicit none +! integer :: x, y, z +! integer :: sum3 +! sum3 = x + y + z +! end function sum3 From 537d60222f1b8ddee0761c551b5a8226cd0f6694 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Tue, 15 Apr 2025 12:23:32 +0300 Subject: [PATCH 02/32] Add Dominator tree builder and interprocedural analysis --- src/CFGraph/CFGraph.h | 8 +- src/ProjectParameters/domTree.h | 111 +++++++++++ src/ProjectParameters/projectParameters.cpp | 203 +++++++++++++++----- src/ProjectParameters/projectParameters.h | 18 +- src/Sapfor.cpp | 4 +- 5 files changed, 289 insertions(+), 55 deletions(-) create mode 100644 src/ProjectParameters/domTree.h diff --git a/src/CFGraph/CFGraph.h b/src/CFGraph/CFGraph.h index 319b420..cdb190b 100644 --- a/src/CFGraph/CFGraph.h +++ b/src/CFGraph/CFGraph.h @@ -24,7 +24,7 @@ namespace SAPFOR std::vector next; std::vector prev; - + BasicBlock* idom{}; //reaching definition std::map> RD_in, RD_out; @@ -42,6 +42,7 @@ namespace SAPFOR void addInstruction(IR_Block* item); void addPrev(BasicBlock* prev_) { prev.push_back(prev_); } void addNext(BasicBlock* next_) { next.push_back(next_); } + void setIdom(BasicBlock* idom_) { idom = idom_; } int removePrev(BasicBlock* removed); int removeNext(BasicBlock* removed); @@ -69,7 +70,8 @@ namespace SAPFOR const std::vector& getInstructions() const { return instructions; } const std::vector& getNext() const { return next; } const std::vector& getPrev() const { return prev; } - + BasicBlock* getIdom() const { return idom; } + /* * FOR LIVE ANALYSIS */ @@ -146,4 +148,4 @@ static inline void deleteCFG(std::map + +using namespace std; + +namespace SAPFOR { +class DominatorFinder { +private: + BasicBlock* entry; + std::vector vertices; + std::unordered_map dfs_num; + std::vector parent, semi, vertex, ancestor, label; + std::vector> bucket; + int n; + + void DFS(BasicBlock* v, int parent_num) { + dfs_num[v] = n; + vertex[n] = n; + semi[n] = n; + label[n] = n; + ancestor[n] = -1; + parent[n] = parent_num; + vertices[n++] = v; + + for (const auto& w : v->getNext()) { + if (dfs_num[w] == -1) { + DFS(w, dfs_num[v]); + } + } + } + + void Compress(int v) { + if (ancestor[ancestor[v]] != -1) { + Compress(ancestor[v]); + if (semi[label[ancestor[v]]] < semi[label[v]]) + label[v] = label[ancestor[v]]; + ancestor[v] = ancestor[ancestor[v]]; + } + } + + int Eval(int v) { + if (ancestor[v] == -1) return v; + Compress(v); + return label[v]; + } + + void Link(int v, int w) { + ancestor[w] = v; + } + +public: + DominatorFinder(std::vector& blocks) { + if (blocks.empty()) return; + entry = blocks[0]; + n = 0; + + for (auto block : blocks) dfs_num[block] = -1; + + int max_size = blocks.size(); + vertices.resize(max_size); + parent.assign(max_size, -1); + semi.assign(max_size, -1); + vertex.assign(max_size, -1); + ancestor.assign(max_size, -1); + label.assign(max_size, -1); + bucket.resize(max_size); + + DFS(entry, -1); + + for (int i = n - 1; i > 0; --i) { + int w = vertex[i]; + + for (BasicBlock* v : vertices[w]->getPrev()) { + int u = Eval(dfs_num[v]); + if (semi[u] < semi[w]) + semi[w] = semi[u]; + } + bucket[vertex[semi[w]]].push_back(w); + Link(parent[w], w); + + for (int v : bucket[parent[w]]) + { + int u = Eval(v); + if (semi[u] < semi[v]) + vertices[v]->setIdom(vertices[u]); + else + vertices[v]->setIdom(vertices[parent[w]]); + } + bucket[parent[w]].clear(); + } + + for (int i = 1; i < n; ++i) { + int w = vertex[i]; + if (vertices[w]->getIdom() != vertices[vertex[semi[w]]]) + vertices[w]->setIdom(vertices[w]->getIdom()->getIdom()); + } + + entry->setIdom(nullptr); + } +}; + +void buildDominatorTreeLT(std::vector& blocks) { + DominatorFinder finder(blocks); +} + +} diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 7ac33d0..4a5f5c6 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -1,10 +1,10 @@ -#include #include #include #include #include #include #include +#include #include #include #include @@ -20,14 +20,43 @@ #include "libSage++.h" #include "projectParameters.h" +#include "domTree.h" using namespace std; +tuple stmtToIR(const map>& CFGraph, SgStatement* stmt) +{ + SgStatement* cur = stmt; + while (cur->variant() != PROC_HEDR && cur->variant() != PROG_HEDR && cur->variant() != FUNC_HEDR) + cur = cur->controlParent(); + + string funcName = ((SgProcHedrStmt*)cur)->nameWithContains(); + + int stmtID = stmt->id(); + for (const auto& [func, bblocks] : CFGraph) + { + if (func->funcName != funcName) + continue; + + for (auto basicBlock : bblocks) + for (auto ins : basicBlock->getInstructions()) + if (stmtID == ins->getInstruction()->getOperator()->id()) + return make_tuple(func, ins->getInstruction(), basicBlock); + } + + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + return { NULL, NULL, NULL }; +} + template -static void processArgument(set& worklist, SAPFOR::Argument* arg, Iterator instr, Iterator first_instr) { +static void processArgument(set& worklist, + SAPFOR::Argument* arg, + Iterator instr, + Iterator first_instr) +{ if (arg == NULL) return; - if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) + if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) extract_vars_from_reg(worklist, arg, instr, first_instr); else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR && arg->getMemType() == SAPFOR::CFG_MEM_TYPE::LOCAL_) { @@ -37,9 +66,14 @@ static void processArgument(set& worklist, SAPFOR::Argument* } template -void extract_vars_from_reg(set& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr) { - for (; instr >= first_instr; instr--) { - if ((*instr)->getInstruction()->getResult() == reg) +static void extract_vars_from_reg(set& worklist, + SAPFOR::Argument* reg, + Iterator instr, + Iterator first_instr) +{ + for (; instr >= first_instr; instr--) + { + if ((*instr)->getInstruction()->getResult() == reg) { processArgument(worklist, (*instr)->getInstruction()->getArg1(), instr, first_instr); processArgument(worklist, (*instr)->getInstruction()->getArg2(), instr, first_instr); @@ -48,14 +82,14 @@ void extract_vars_from_reg(set& worklist, SAPFOR::Argument* r } } -static void lookup_for_vars(ResultSet& result_set, +static void lookup_for_vars(std::map& where_to_add, set& worklist, SAPFOR::Instruction* instr, SAPFOR::BasicBlock* bblock, const std::map>& fullIR) { std::cout << "Lookup in bblock no." << bblock->getNumber() << std::endl; //DEBUG PRINT - + auto first_instr = bblock->getInstructions().begin(); auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { return i->getInstruction() == instr; @@ -63,7 +97,7 @@ static void lookup_for_vars(ResultSet& result_set, for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) { - auto instr = (*cur_instr)->getInstruction(); + auto instr = (*cur_instr)->getInstruction(); auto result_arg = instr->getResult(); auto arg1 = instr->getArg1(); auto arg2 = instr->getArg2(); @@ -75,37 +109,37 @@ static void lookup_for_vars(ResultSet& result_set, std::cout << "worklist erase: " << result_arg->getValue() << std::endl; //DEBUG PRINT worklist.erase(result_arg); } - if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) + if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) { // skip to F_CALL auto f_call_instr = cur_instr; while ((*f_call_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL) f_call_instr++; - if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ") + if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ") { - auto filename = (*f_call_instr)->getInstruction()->getOperator()->fileName(); - auto line = (*f_call_instr)->getInstruction()->getOperator()->lineNumber(); + auto stmt_before = (*f_call_instr)->getInstruction()->getOperator(); + auto filename = stmt_before->fileName(); + auto line = stmt_before->lineNumber(); + auto var_name = arg1->getValue().substr(arg1->getValue().find('%') + 1); __spf_print(1,"Please specify value of variable %s on line %d of file %s", arg1->getValue().c_str(), line, filename); - result_set.insert(make_tuple(filename, line, arg1->getValue())); - + where_to_add[stmt_before] = var_name; std::cout << "worklist erase: " << arg1->getValue() << std::endl; //DEBUG PRINT worklist.erase(arg1); - } else + } else { //check if variable is modified in called function } } } - const auto& RD = bblock->getRD_In(); map group_by_block; - for (auto& arg : worklist) + for (auto& arg : worklist) { if (RD.count(arg)) { - if (RD.at(arg).size() == 0) + if (RD.at(arg).size() == 1 && *RD.at(arg).begin() == SAPFOR::CFG_VAL::UNINIT) __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); else if (RD.at(arg).size() > 1) __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible", arg->getValue().c_str()); @@ -114,24 +148,31 @@ static void lookup_for_vars(ResultSet& result_set, for (const auto& instr_num : RD.at(arg)) { auto [instr, bblock] = getInstructionAndBlockByNumber(fullIR, instr_num); - if (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) + if (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) group_by_block[bblock] = instr; } } } } - for (const auto& [bblock, instr] : group_by_block) + auto idom = bblock->getIdom(); + while (idom != NULL) { - lookup_for_vars(result_set, worklist, instr, bblock, fullIR); + if (group_by_block.count(idom)) + { + lookup_for_vars(where_to_add, worklist, group_by_block[idom], idom, fullIR); + return; + } + idom = idom->getIdom(); } } -static void handle_single_allocate(ResultSet& result_set, - SAPFOR::Instruction* instr, - SAPFOR::BasicBlock* bblock, +static void handle_single_allocate(std::map& where_to_add, + SgStatement* alloc_statement, const std::map>& fullIR) -{ +{ + auto [func, instr, bblock] = stmtToIR(fullIR, alloc_statement); + auto first_instr = bblock->getInstructions().begin(); auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { return i->getInstruction() == instr; @@ -140,7 +181,7 @@ static void handle_single_allocate(ResultSet& result_set, // skip to F_CALL _ALLOC n while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL || - (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") + (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") { alloc_instr++; } @@ -161,11 +202,11 @@ static void handle_single_allocate(ResultSet& result_set, } auto dimensions_num = stoi((*param_instr)->getInstruction()->getArg2()->getValue()); - + for (int j = 0; j < dimensions_num; j++) { auto ref_instr = --param_instr; - + auto arg = (*ref_instr)->getInstruction()->getArg1(); if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) { @@ -178,33 +219,107 @@ static void handle_single_allocate(ResultSet& result_set, } } } - lookup_for_vars(result_set,worklist, instr, bblock, fullIR); + lookup_for_vars(where_to_add,worklist, instr, bblock, fullIR); } -ResultSet -findParameters(const std::map>& fullIR, +static void handle_single_loop(std::map& where_to_add, + SgStatement* loop_stmt, + const std::map>& fullIR) +{ + auto [func_name, instr, bblock] = stmtToIR(fullIR, loop_stmt); + std::cout << "bblock: " << bblock->getNumber() << " instr: " << instr->getNumber() << std::endl; + + auto cur_instr = bblock->getInstructions().end() - 1; + + set worklist; + extract_vars_from_reg(worklist, (*cur_instr)->getInstruction()->getResult(), cur_instr, bblock->getInstructions().begin()); + + lookup_for_vars(where_to_add, worklist, (*cur_instr)->getInstruction(), bblock, fullIR); +} + +void +findParameters(ResultSet& foundParameters, + std::map>& fullIR, const std::map, std::pair>& declaredArrays) { - ResultSet foundParameters; + map where_to_add; + + map name_to_func; + for (const auto& [func, _] : fullIR) + name_to_func[func->funcName] = func; + + map> call_sites; + for (auto& [func, bblocks] : fullIR) + { + for (const auto& block : bblocks) + { + for (const auto& ir_block : block->getInstructions()) + { + auto instr = ir_block->getInstruction(); + if (instr->getOperation() == SAPFOR::CFG_OP::F_CALL) + { + auto func_name = instr->getArg1()->getValue(); + auto func_info = name_to_func.find(func_name); + + if (func_info != name_to_func.end()) + call_sites[func_info->second].push_back(instr); + } + } + } + + SAPFOR::buildDominatorTreeLT(bblocks); + for (auto block : bblocks) + { + if (block->getIdom() != NULL) + std::cout << "BB: " << block->getNumber() << " IDOM: " << block->getIdom()->getNumber() << std::endl; + } + std::cout << "+++++++++++\n"; + } + std::set alloc_statements; - for (const auto& elem : declaredArrays) + for (const auto& elem : declaredArrays) { const auto& array = elem.second.first; - assert(array->GetLocation().first == Distribution::arrayLocation::l_LOCAL); // v0.1 - SgSymbol* arraySymb = array->GetDeclSymbol()->GetOriginal(); SgStatement* decl = declaratedInStmt(arraySymb); - for (auto &stmt : getAttributes(decl, set{ ALLOCATE_STMT })) - { + + for (auto& stmt : getAttributes(decl, set{ ALLOCATE_STMT })) alloc_statements.insert(stmt); - } } - + for (const auto& alloc_statement : alloc_statements) { - auto [instr, bblock] = getInstructionAndBlockByStatement(fullIR, alloc_statement); - ResultSet result_set; - handle_single_allocate(result_set, instr, bblock, fullIR); + handle_single_allocate(where_to_add, alloc_statement, fullIR); + } + + set for_statements; + // Find all FOR statements in the program + for (const auto& [func, bblocks] : fullIR) + for (const auto& block : bblocks) + for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) + { + auto op = (*instr)->getInstruction()->getOperator(); + if (op && op->variant() == FOR_NODE) { + std::cout << block->getNumber() << std::endl; + for_statements.insert(op); + } + } + + for (const auto& stmt : for_statements) + { + handle_single_loop(where_to_add, stmt, fullIR); + } + + for (const auto& [stmt_before, var_name] : where_to_add) + { + // SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); + // SgVarRefExp* var = new SgVarRefExp(var_symb); + // SgValueExp* zero = new SgValueExp(0); + // SgExprListExp* ex = new SgExprListExp(); + // ex->setLhs(new SgExpression(ASSGN_OP, var, zero)); + // SgStatement* toAdd = new SgStatement(SPF_PARAMETER_OP, NULL, NULL, ex, NULL, NULL); + // stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); + + foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name)); } - return foundParameters; } diff --git a/src/ProjectParameters/projectParameters.h b/src/ProjectParameters/projectParameters.h index 25e32e4..36547b7 100644 --- a/src/ProjectParameters/projectParameters.h +++ b/src/ProjectParameters/projectParameters.h @@ -1,5 +1,6 @@ #pragma once +#include "libSage++.h" #include #include #include @@ -7,18 +8,25 @@ using ResultSet = std::set>; template -void extract_vars_from_reg(std::set& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr); +static void extract_vars_from_reg(std::set& worklist, + SAPFOR::Argument* reg, + Iterator instr, + Iterator first_instr); template -static void processArgument(std::set& worklist, SAPFOR::Argument* arg, Iterator instr, Iterator first_instr); +static void processArgument(std::set& worklist, + SAPFOR::Argument* arg, + Iterator instr, + Iterator first_instr); -static void lookup_for_vars(ResultSet& result_set, +static void lookup_for_vars(std::map& where_to_add, std::set& worklist, SAPFOR::Instruction* instr, SAPFOR::BasicBlock* bblock, const std::map>& fullIR); -ResultSet -findParameters(const std::map>& fullIR, +void +findParameters(ResultSet& foundParameters, + std::map>& fullIR, const std::map, std::pair>& declaredArrays); diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index cbdaa32..c5a4cf2 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -1895,9 +1895,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne runRenameSymbols(&project, commonBlocks); else if (curr_regime == FIND_PARAMETERS) { - performRDSubst(fullIR, commonBlocks, &project); - parametersOfProject = findParameters(fullIR, declaredArrays); - performRDSubst(fullIR, commonBlocks, &project); + findParameters(parametersOfProject, fullIR, declaredArrays); } else if (curr_regime == BUILD_IR) { From f9d52c0c3ee343147c3f452fea9f929f0c690e95 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Tue, 15 Apr 2025 18:45:04 +0300 Subject: [PATCH 03/32] unparse after --- src/Sapfor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index c5a4cf2..bb4e093 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2340,6 +2340,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case INSERT_NO_DISTR_FLAGS_FROM_GUI: case PRIVATE_REMOVING: case RENAME_INLCUDES: + case FIND_PARAMETERS: runAnalysis(*project, curr_regime, true, "", folderName); break; case INLINE_PROCEDURES: @@ -2375,7 +2376,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case FIX_COMMON_BLOCKS: case TEST_PASS: case SET_IMPLICIT_NONE: - case FIND_PARAMETERS: runAnalysis(*project, curr_regime, false); case SUBST_EXPR_RD_AND_UNPARSE: case SUBST_EXPR_AND_UNPARSE: From 8b2e59356aa24d6f4003a09b736ddebaf4201252 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Thu, 1 May 2025 11:43:35 +0300 Subject: [PATCH 04/32] Extend interprocedural analysis --- src/ProjectParameters/projectParameters.cpp | 339 +++++++++++++------- src/ProjectParameters/projectParameters.h | 36 ++- 2 files changed, 249 insertions(+), 126 deletions(-) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 4a5f5c6..9919a51 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -27,6 +27,7 @@ using namespace std; tuple stmtToIR(const map>& CFGraph, SgStatement* stmt) { SgStatement* cur = stmt; + cur->switchToFile(); while (cur->variant() != PROC_HEDR && cur->variant() != PROG_HEDR && cur->variant() != FUNC_HEDR) cur = cur->controlParent(); @@ -48,17 +49,31 @@ tuple stmtToIR(const map IRByNumber(const map>& CFGraph, int num) +{ + if (num < 0) + return { NULL, NULL, NULL }; + + for (const auto& [func, bblocks] : CFGraph) + for (auto byBB : bblocks) + if (byBB->getInstructions().front()->getNumber() <= num && byBB->getInstructions().back()->getNumber() >= num) + return make_tuple(func, getInstructionByNumber(byBB->getInstructions(), num), byBB); + + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + return { NULL, NULL, NULL}; +} + template -static void processArgument(set& worklist, - SAPFOR::Argument* arg, - Iterator instr, - Iterator first_instr) +void processArgument(set& worklist, + SAPFOR::Argument* arg, + Iterator instr, + Iterator first_instr) { if (arg == NULL) return; if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) extract_vars_from_reg(worklist, arg, instr, first_instr); - else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR && arg->getMemType() == SAPFOR::CFG_MEM_TYPE::LOCAL_) + else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR) { std::cout << "worklist add: " << arg->getValue() << std::endl; //DEBUG PRINT worklist.insert(arg); @@ -66,10 +81,10 @@ static void processArgument(set& worklist, } template -static void extract_vars_from_reg(set& worklist, - SAPFOR::Argument* reg, - Iterator instr, - Iterator first_instr) +void extract_vars_from_reg(set& worklist, + SAPFOR::Argument* reg, + Iterator instr, + Iterator first_instr) { for (; instr >= first_instr; instr--) { @@ -82,94 +97,180 @@ static void extract_vars_from_reg(set& worklist, } } -static void lookup_for_vars(std::map& where_to_add, - set& worklist, - SAPFOR::Instruction* instr, - SAPFOR::BasicBlock* bblock, - const std::map>& fullIR) +void lookup_for_vars(std::set>& where_to_add, + set& worklist, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + FuncInfo* cur_func, + const std::map>& fullIR) { - std::cout << "Lookup in bblock no." << bblock->getNumber() << std::endl; //DEBUG PRINT - - auto first_instr = bblock->getInstructions().begin(); - auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { - return i->getInstruction() == instr; - }); - - for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) + while (bblock) { - auto instr = (*cur_instr)->getInstruction(); - auto result_arg = instr->getResult(); - auto arg1 = instr->getArg1(); - auto arg2 = instr->getArg2(); + std::cout << "Lookup in bblock no." << bblock->getNumber() << std::endl; //DEBUG PRINT - if (worklist.count(result_arg)) - { - processArgument(worklist, arg1, cur_instr, first_instr); - processArgument(worklist, arg2, cur_instr, first_instr); - std::cout << "worklist erase: " << result_arg->getValue() << std::endl; //DEBUG PRINT - worklist.erase(result_arg); - } - if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) - { - // skip to F_CALL - auto f_call_instr = cur_instr; - while ((*f_call_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL) - f_call_instr++; + auto first_instr = bblock->getInstructions().begin(); + auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { + return i->getInstruction() == instr; + }); - if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ") + for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) + { + auto instr = (*cur_instr)->getInstruction(); + // std::cout << instr->getNumber() << '\n'; + auto result_arg = instr->getResult(); + auto arg1 = instr->getArg1(); + auto arg2 = instr->getArg2(); + + if (worklist.count(result_arg)) { - auto stmt_before = (*f_call_instr)->getInstruction()->getOperator(); - auto filename = stmt_before->fileName(); - auto line = stmt_before->lineNumber(); - auto var_name = arg1->getValue().substr(arg1->getValue().find('%') + 1); - __spf_print(1,"Please specify value of variable %s on line %d of file %s", arg1->getValue().c_str(), line, filename); - where_to_add[stmt_before] = var_name; - std::cout << "worklist erase: " << arg1->getValue() << std::endl; //DEBUG PRINT - worklist.erase(arg1); - } else + processArgument(worklist, arg1, cur_instr, first_instr); + processArgument(worklist, arg2, cur_instr, first_instr); + std::cout << "worklist erase: " << result_arg->getValue() << std::endl; //DEBUG PRINT + worklist.erase(result_arg); + } + if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) { - //check if variable is modified in called function + // skip to F_CALL + auto f_call_instr = cur_instr; + while ((*f_call_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL) + f_call_instr++; + + if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ") + { + auto stmt_before = (*f_call_instr)->getInstruction()->getOperator(); + auto filename = stmt_before->fileName(); + auto line = stmt_before->lineNumber(); + auto var_name = arg1->getValue().substr(arg1->getValue().find('%') + 1); + __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg1->getValue().c_str(), line, filename); + auto toAdd = make_tuple(stmt_before, var_name, MODE::AFTER); + where_to_add.insert(toAdd); + std::cout << "worklist erase: " << arg1->getValue() << std::endl; //DEBUG PRINT + worklist.erase(arg1); + } } } - } - const auto& RD = bblock->getRD_In(); - map group_by_block; - for (auto& arg : worklist) - { - if (RD.count(arg)) + const auto& RD = bblock->getRD_In(); + map group_by_block; + for (auto& arg : worklist) { - if (RD.at(arg).size() == 1 && *RD.at(arg).begin() == SAPFOR::CFG_VAL::UNINIT) - __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); - else if (RD.at(arg).size() > 1) - __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible", arg->getValue().c_str()); - else + if (RD.count(arg)) { - for (const auto& instr_num : RD.at(arg)) + if (RD.at(arg).size() == 1 && *RD.at(arg).begin() == SAPFOR::CFG_VAL::UNINIT) + __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); + else if (RD.at(arg).size() > 1) { - auto [instr, bblock] = getInstructionAndBlockByNumber(fullIR, instr_num); - if (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) + auto stmt_after = (*first_instr)->getInstruction()->getOperator(); + auto filename = stmt_after->fileName(); + auto line = stmt_after->lineNumber(); + auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1); + __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str()); + __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); + auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); + where_to_add.insert(toAdd); + std::cout << "worklist erase: " << arg->getValue() << std::endl; //DEBUG PRINT + worklist.erase(arg); + } + else + { + auto instr_num = *RD.at(arg).begin(); + auto [func, instr, bblock] = IRByNumber(fullIR, instr_num); + if (cur_func == func && group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) group_by_block[bblock] = instr; } } } + + while (bblock && group_by_block.find(bblock) == group_by_block.end()) + bblock = bblock->getIdom(); + if (bblock) + instr = group_by_block[bblock]; } - auto idom = bblock->getIdom(); - while (idom != NULL) + // other variables are from global scope + const auto& RD = fullIR.at(cur_func).front()->getRD_In(); + for (auto& arg : worklist) { - if (group_by_block.count(idom)) + if (arg->isMemGlobal()) { - lookup_for_vars(where_to_add, worklist, group_by_block[idom], idom, fullIR); - return; + std::cout << "global: " << arg->getValue() << " : " << RD.count(arg) << '\n'; + set found_rd; + if (RD.count(arg)) + found_rd = RD.at(arg); + if (found_rd.size() == 0) + { + auto call_instr = call_sites[cur_func].size() ? call_sites[cur_func].front() : NULL; + while (call_instr && found_rd.size() == 0) + { + auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber()); + std::cout << "caller: " << call_func->funcName << '\n'; + if (call_bblock->getRD_Out().count(arg)) + { + std::cout << *call_bblock->getRD_Out().at(arg).begin() << "\n"; + found_rd = call_bblock->getRD_Out().at(arg); + } + + call_instr = call_sites[call_func].size() ? call_sites[call_func].front() : NULL; + } + } + if (found_rd.size() == 1 && *found_rd.begin() == SAPFOR::CFG_VAL::UNINIT) + { + __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); + } else if (found_rd.size() > 1) + { + auto first_instr = fullIR.at(cur_func).front()->getInstructions().begin(); + auto stmt_after = (*first_instr)->getInstruction()->getOperator(); + auto filename = stmt_after->fileName(); + auto line = stmt_after->lineNumber(); + auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1); + __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str()); + __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); + auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); + where_to_add.insert(toAdd); + } + else + { + auto instr_num = *found_rd.begin(); + auto [func, instr, bblock] = IRByNumber(fullIR, instr_num); + set new_worklist = {arg}; + + lookup_for_vars(where_to_add, new_worklist, instr, bblock, func, fullIR); + } } - idom = idom->getIdom(); } + + + for (const auto& call_instr : call_sites[cur_func]) + { + set new_worklist; + auto params_num = cur_func->funcParams.countOfPars; + + auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber()); + std::cout << "caller: " << call_func->funcName << '\n'; + auto first_instr = call_bblock->getInstructions().begin(); + auto cur_instr = std::find_if(first_instr, call_bblock->getInstructions().end(), [call_instr](SAPFOR::IR_Block* i) { + return i->getInstruction() == call_instr; + }); + for (auto& arg : worklist) + { + if (arg->getMemType() == SAPFOR::CFG_MEM_TYPE::FUNC_PARAM_) + { + auto param_num= stoi(arg->getValue().substr(arg->getValue().find('%', arg->getValue().find('%') + 1) + 1)); + // std::cout << params_num << '\n'; + auto param_instr = (cur_instr - (params_num - param_num)); + auto param_arg = (*param_instr)->getInstruction()->getArg1(); + std::cout << "param_val: " << param_arg->getValue() << " : " << param_num << '\n'; + processArgument(new_worklist, param_arg, param_instr, first_instr); + } + } + lookup_for_vars(where_to_add, new_worklist, call_instr, call_bblock, call_func, fullIR); + } + } -static void handle_single_allocate(std::map& where_to_add, - SgStatement* alloc_statement, - const std::map>& fullIR) +void handle_single_allocate(std::set>& where_to_add, + SgStatement* alloc_statement, + const std::map>& fullIR) { auto [func, instr, bblock] = stmtToIR(fullIR, alloc_statement); @@ -182,9 +283,8 @@ static void handle_single_allocate(std::map& where_to // skip to F_CALL _ALLOC n while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL || (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") - { alloc_instr++; - } + auto arrays_num = stoi((*alloc_instr)->getInstruction()->getArg2()->getValue()); std::cout << "arrays_num: " << arrays_num << std::endl; //DEBUG PRINT @@ -197,36 +297,41 @@ static void handle_single_allocate(std::map& where_to while ((*param_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::LOAD || (*param_instr)->getInstruction()->getResult() != param_reg) - { param_instr--; - } + auto dimensions_num = stoi((*param_instr)->getInstruction()->getArg2()->getValue()); for (int j = 0; j < dimensions_num; j++) { auto ref_instr = --param_instr; - - auto arg = (*ref_instr)->getInstruction()->getArg1(); - if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) + if ((*ref_instr)->getInstruction()->getOperation() == SAPFOR::CFG_OP::RANGE) { - extract_vars_from_reg(worklist, arg, ref_instr, first_instr); - } - else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR && arg->getMemType() == SAPFOR::CFG_MEM_TYPE::LOCAL_) + vector range_args = {(*ref_instr)->getInstruction()->getArg1(), + (*ref_instr)->getInstruction()->getArg2(), + (*ref_instr)->getInstruction()->getResult()}; + for (auto& arg : range_args) + { + if (arg) + std::cout << "range-arg: " << arg->getValue() << '\n'; + processArgument(worklist, arg, ref_instr, first_instr); + } + } else { - std::cout << "worklist add: " << arg->getValue() << std::endl; //DEBUG PRINT - worklist.insert(arg); + auto arg = (*ref_instr)->getInstruction()->getArg1(); + processArgument(worklist, arg, ref_instr, first_instr); } } } - lookup_for_vars(where_to_add,worklist, instr, bblock, fullIR); + lookup_for_vars(where_to_add,worklist, instr, bblock, func, fullIR); } -static void handle_single_loop(std::map& where_to_add, - SgStatement* loop_stmt, - const std::map>& fullIR) + +void handle_single_loop(std::set>& where_to_add, + SgStatement* loop_stmt, + const std::map>& fullIR) { - auto [func_name, instr, bblock] = stmtToIR(fullIR, loop_stmt); + auto [func, instr, bblock] = stmtToIR(fullIR, loop_stmt); std::cout << "bblock: " << bblock->getNumber() << " instr: " << instr->getNumber() << std::endl; auto cur_instr = bblock->getInstructions().end() - 1; @@ -234,7 +339,7 @@ static void handle_single_loop(std::map& where_to_add set worklist; extract_vars_from_reg(worklist, (*cur_instr)->getInstruction()->getResult(), cur_instr, bblock->getInstructions().begin()); - lookup_for_vars(where_to_add, worklist, (*cur_instr)->getInstruction(), bblock, fullIR); + lookup_for_vars(where_to_add, worklist, (*cur_instr)->getInstruction(), bblock, func, fullIR); } void @@ -242,13 +347,12 @@ findParameters(ResultSet& foundParameters, std::map>& fullIR, const std::map, std::pair>& declaredArrays) { - map where_to_add; + set> where_to_add; map name_to_func; for (const auto& [func, _] : fullIR) name_to_func[func->funcName] = func; - map> call_sites; for (auto& [func, bblocks] : fullIR) { for (const auto& block : bblocks) @@ -277,18 +381,19 @@ findParameters(ResultSet& foundParameters, } std::set alloc_statements; - for (const auto& elem : declaredArrays) - { - const auto& array = elem.second.first; - SgSymbol* arraySymb = array->GetDeclSymbol()->GetOriginal(); - SgStatement* decl = declaratedInStmt(arraySymb); - - for (auto& stmt : getAttributes(decl, set{ ALLOCATE_STMT })) - alloc_statements.insert(stmt); - } + for (const auto& [func, bblocks] : fullIR) + for (const auto& block : bblocks) + for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) + { + auto op = (*instr)->getInstruction()->getOperator(); + if (op && op->variant() == ALLOCATE_STMT) { + alloc_statements.insert(op); + } + } for (const auto& alloc_statement : alloc_statements) { + alloc_statement->unparsestdout(); handle_single_allocate(where_to_add, alloc_statement, fullIR); } @@ -299,26 +404,34 @@ findParameters(ResultSet& foundParameters, for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) { auto op = (*instr)->getInstruction()->getOperator(); - if (op && op->variant() == FOR_NODE) { - std::cout << block->getNumber() << std::endl; + if (op && op->variant() == FOR_NODE) for_statements.insert(op); - } } for (const auto& stmt : for_statements) { + std::cout << string(stmt->fileName()) << ":" << stmt->lineNumber() << '\n'; handle_single_loop(where_to_add, stmt, fullIR); } - for (const auto& [stmt_before, var_name] : where_to_add) + for (const auto& [stmt_before, var_name, mode] : where_to_add) { - // SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); - // SgVarRefExp* var = new SgVarRefExp(var_symb); - // SgValueExp* zero = new SgValueExp(0); - // SgExprListExp* ex = new SgExprListExp(); - // ex->setLhs(new SgExpression(ASSGN_OP, var, zero)); - // SgStatement* toAdd = new SgStatement(SPF_PARAMETER_OP, NULL, NULL, ex, NULL, NULL); - // stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); + stmt_before->switchToFile(); + SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); + SgVarRefExp* var = new SgVarRefExp(var_symb); + SgValueExp* zero = new SgValueExp(1337); + SgExprListExp* ex = new SgExprListExp(); + ex->setLhs(new SgExpression(ASSGN_OP, var, zero)); + std::cout << "stmt_before: " << stmt_before->unparse(); + SgStatement* toAdd = new SgStatement(ASSIGN_STAT, NULL, NULL, var, zero, NULL); + toAdd->unparsestdout(); + // toAdd->lineNumber() = stmt_before->lineNumber(); + toAdd->setlineNumber(stmt_before->lineNumber()); + toAdd->setLocalLineNumber(stmt_before->lineNumber()); + toAdd->setFileId(stmt_before->getFileId()); + toAdd->setProject(stmt_before->getProject()); + stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); + stmt_before->controlParent()->unparsestdout(); foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name)); } diff --git a/src/ProjectParameters/projectParameters.h b/src/ProjectParameters/projectParameters.h index 36547b7..1181560 100644 --- a/src/ProjectParameters/projectParameters.h +++ b/src/ProjectParameters/projectParameters.h @@ -4,27 +4,37 @@ #include #include #include +#include using ResultSet = std::set>; +enum class MODE +{ + BEFORE, + AFTER +}; + +static std::map> call_sites; + template -static void extract_vars_from_reg(std::set& worklist, - SAPFOR::Argument* reg, - Iterator instr, - Iterator first_instr); +void extract_vars_from_reg(std::set& worklist, + SAPFOR::Argument* reg, + Iterator instr, + Iterator first_instr); template -static void processArgument(std::set& worklist, - SAPFOR::Argument* arg, - Iterator instr, - Iterator first_instr); +void processArgument(std::set& worklist, + SAPFOR::Argument* arg, + Iterator instr, + Iterator first_instr); -static void lookup_for_vars(std::map& where_to_add, - std::set& worklist, - SAPFOR::Instruction* instr, - SAPFOR::BasicBlock* bblock, - const std::map>& fullIR); +void lookup_for_vars(std::set>& where_to_add, + std::set& worklist, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + FuncInfo* cur_func, + const std::map>& fullIR); void findParameters(ResultSet& foundParameters, From 6742932862a27227dd8257c5cf9cdaa2d8447b6b Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Thu, 1 May 2025 18:43:51 +0300 Subject: [PATCH 05/32] Add SPF directive insertion --- src/ProjectParameters/projectParameters.cpp | 15 ++++++++++++--- src/Sapfor.cpp | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 9919a51..cad6738 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -175,7 +175,7 @@ void lookup_for_vars(std::set>& wher { auto instr_num = *RD.at(arg).begin(); auto [func, instr, bblock] = IRByNumber(fullIR, instr_num); - if (cur_func == func && group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num) + if (cur_func == func && (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num)) group_by_block[bblock] = instr; } } @@ -421,17 +421,26 @@ findParameters(ResultSet& foundParameters, SgVarRefExp* var = new SgVarRefExp(var_symb); SgValueExp* zero = new SgValueExp(1337); SgExprListExp* ex = new SgExprListExp(); + auto op = new SgExpression(ASSGN_OP, var, zero); + + std::cout << "len: " << ex->length() << '\n'; ex->setLhs(new SgExpression(ASSGN_OP, var, zero)); std::cout << "stmt_before: " << stmt_before->unparse(); - SgStatement* toAdd = new SgStatement(ASSIGN_STAT, NULL, NULL, var, zero, NULL); + SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex); + auto ex2 = new SgExprListExp(); + ex2->setLhs(parameter_op); + SgStatement* toAdd = new SgStatement(SPF_ANALYSIS_DIR, NULL, NULL, ex2, NULL, NULL); toAdd->unparsestdout(); // toAdd->lineNumber() = stmt_before->lineNumber(); toAdd->setlineNumber(stmt_before->lineNumber()); toAdd->setLocalLineNumber(stmt_before->lineNumber()); toAdd->setFileId(stmt_before->getFileId()); toAdd->setProject(stmt_before->getProject()); - stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); stmt_before->controlParent()->unparsestdout(); + if (mode == MODE::AFTER) + stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); + else + stmt_before->insertStmtBefore(*toAdd, *stmt_before->controlParent()); foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name)); } diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index bb4e093..2bee6a5 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2340,7 +2340,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case INSERT_NO_DISTR_FLAGS_FROM_GUI: case PRIVATE_REMOVING: case RENAME_INLCUDES: - case FIND_PARAMETERS: runAnalysis(*project, curr_regime, true, "", folderName); break; case INLINE_PROCEDURES: @@ -2375,6 +2374,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case LOOPS_COMBINER: case FIX_COMMON_BLOCKS: case TEST_PASS: + case FIND_PARAMETERS: case SET_IMPLICIT_NONE: runAnalysis(*project, curr_regime, false); case SUBST_EXPR_RD_AND_UNPARSE: From 4e16638c363ee33d7119ec0e785d48aec2d75d62 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Thu, 1 May 2025 18:52:29 +0300 Subject: [PATCH 06/32] Clean up --- src/ProjectParameters/projectParameters.cpp | 92 +++++++-------------- 1 file changed, 29 insertions(+), 63 deletions(-) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index cad6738..4bf0fec 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -53,12 +53,12 @@ tuple IRByNumber(const map { if (num < 0) return { NULL, NULL, NULL }; - + for (const auto& [func, bblocks] : CFGraph) for (auto byBB : bblocks) if (byBB->getInstructions().front()->getNumber() <= num && byBB->getInstructions().back()->getNumber() >= num) return make_tuple(func, getInstructionByNumber(byBB->getInstructions(), num), byBB); - + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); return { NULL, NULL, NULL}; } @@ -75,7 +75,6 @@ void processArgument(set& worklist, extract_vars_from_reg(worklist, arg, instr, first_instr); else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR) { - std::cout << "worklist add: " << arg->getValue() << std::endl; //DEBUG PRINT worklist.insert(arg); } } @@ -106,8 +105,6 @@ void lookup_for_vars(std::set>& wher { while (bblock) { - std::cout << "Lookup in bblock no." << bblock->getNumber() << std::endl; //DEBUG PRINT - auto first_instr = bblock->getInstructions().begin(); auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { return i->getInstruction() == instr; @@ -116,7 +113,6 @@ void lookup_for_vars(std::set>& wher for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) { auto instr = (*cur_instr)->getInstruction(); - // std::cout << instr->getNumber() << '\n'; auto result_arg = instr->getResult(); auto arg1 = instr->getArg1(); auto arg2 = instr->getArg2(); @@ -125,7 +121,6 @@ void lookup_for_vars(std::set>& wher { processArgument(worklist, arg1, cur_instr, first_instr); processArgument(worklist, arg2, cur_instr, first_instr); - std::cout << "worklist erase: " << result_arg->getValue() << std::endl; //DEBUG PRINT worklist.erase(result_arg); } if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) @@ -144,7 +139,6 @@ void lookup_for_vars(std::set>& wher __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg1->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_before, var_name, MODE::AFTER); where_to_add.insert(toAdd); - std::cout << "worklist erase: " << arg1->getValue() << std::endl; //DEBUG PRINT worklist.erase(arg1); } } @@ -157,7 +151,7 @@ void lookup_for_vars(std::set>& wher if (RD.count(arg)) { if (RD.at(arg).size() == 1 && *RD.at(arg).begin() == SAPFOR::CFG_VAL::UNINIT) - __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); + __spf_print(1, "variable %s has no definition\n", arg->getValue().c_str()); else if (RD.at(arg).size() > 1) { auto stmt_after = (*first_instr)->getInstruction()->getOperator(); @@ -168,7 +162,6 @@ void lookup_for_vars(std::set>& wher __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); where_to_add.insert(toAdd); - std::cout << "worklist erase: " << arg->getValue() << std::endl; //DEBUG PRINT worklist.erase(arg); } else @@ -191,9 +184,8 @@ void lookup_for_vars(std::set>& wher const auto& RD = fullIR.at(cur_func).front()->getRD_In(); for (auto& arg : worklist) { - if (arg->isMemGlobal()) + if (arg->isMemGlobal()) { - std::cout << "global: " << arg->getValue() << " : " << RD.count(arg) << '\n'; set found_rd; if (RD.count(arg)) found_rd = RD.at(arg); @@ -203,19 +195,16 @@ void lookup_for_vars(std::set>& wher while (call_instr && found_rd.size() == 0) { auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber()); - std::cout << "caller: " << call_func->funcName << '\n'; - if (call_bblock->getRD_Out().count(arg)) - { - std::cout << *call_bblock->getRD_Out().at(arg).begin() << "\n"; + if (call_bblock->getRD_Out().count(arg)) found_rd = call_bblock->getRD_Out().at(arg); - } - + + call_instr = call_sites[call_func].size() ? call_sites[call_func].front() : NULL; } } if (found_rd.size() == 1 && *found_rd.begin() == SAPFOR::CFG_VAL::UNINIT) { - __spf_print(1, "variable %s has no definition", arg->getValue().c_str()); + __spf_print(1, "variable %s has no definition\n", arg->getValue().c_str()); } else if (found_rd.size() > 1) { auto first_instr = fullIR.at(cur_func).front()->getInstructions().begin(); @@ -233,8 +222,8 @@ void lookup_for_vars(std::set>& wher auto instr_num = *found_rd.begin(); auto [func, instr, bblock] = IRByNumber(fullIR, instr_num); set new_worklist = {arg}; - - lookup_for_vars(where_to_add, new_worklist, instr, bblock, func, fullIR); + + lookup_for_vars(where_to_add, new_worklist, instr, bblock, func, fullIR); } } } @@ -246,7 +235,6 @@ void lookup_for_vars(std::set>& wher auto params_num = cur_func->funcParams.countOfPars; auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber()); - std::cout << "caller: " << call_func->funcName << '\n'; auto first_instr = call_bblock->getInstructions().begin(); auto cur_instr = std::find_if(first_instr, call_bblock->getInstructions().end(), [call_instr](SAPFOR::IR_Block* i) { return i->getInstruction() == call_instr; @@ -256,10 +244,8 @@ void lookup_for_vars(std::set>& wher if (arg->getMemType() == SAPFOR::CFG_MEM_TYPE::FUNC_PARAM_) { auto param_num= stoi(arg->getValue().substr(arg->getValue().find('%', arg->getValue().find('%') + 1) + 1)); - // std::cout << params_num << '\n'; auto param_instr = (cur_instr - (params_num - param_num)); auto param_arg = (*param_instr)->getInstruction()->getArg1(); - std::cout << "param_val: " << param_arg->getValue() << " : " << param_num << '\n'; processArgument(new_worklist, param_arg, param_instr, first_instr); } } @@ -284,10 +270,9 @@ void handle_single_allocate(std::set>& wh while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL || (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") alloc_instr++; - + auto arrays_num = stoi((*alloc_instr)->getInstruction()->getArg2()->getValue()); - std::cout << "arrays_num: " << arrays_num << std::endl; //DEBUG PRINT set worklist; for (int i = 0; i < arrays_num; i++) @@ -298,7 +283,7 @@ void handle_single_allocate(std::set>& wh while ((*param_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::LOAD || (*param_instr)->getInstruction()->getResult() != param_reg) param_instr--; - + auto dimensions_num = stoi((*param_instr)->getInstruction()->getArg2()->getValue()); @@ -310,16 +295,13 @@ void handle_single_allocate(std::set>& wh vector range_args = {(*ref_instr)->getInstruction()->getArg1(), (*ref_instr)->getInstruction()->getArg2(), (*ref_instr)->getInstruction()->getResult()}; - for (auto& arg : range_args) - { - if (arg) - std::cout << "range-arg: " << arg->getValue() << '\n'; + for (auto& arg : range_args) processArgument(worklist, arg, ref_instr, first_instr); - } + } else { auto arg = (*ref_instr)->getInstruction()->getArg1(); - processArgument(worklist, arg, ref_instr, first_instr); + processArgument(worklist, arg, ref_instr, first_instr); } } } @@ -332,7 +314,6 @@ void handle_single_loop(std::set>& where_ const std::map>& fullIR) { auto [func, instr, bblock] = stmtToIR(fullIR, loop_stmt); - std::cout << "bblock: " << bblock->getNumber() << " instr: " << instr->getNumber() << std::endl; auto cur_instr = bblock->getInstructions().end() - 1; @@ -356,7 +337,6 @@ findParameters(ResultSet& foundParameters, for (auto& [func, bblocks] : fullIR) { for (const auto& block : bblocks) - { for (const auto& ir_block : block->getInstructions()) { auto instr = ir_block->getInstruction(); @@ -369,15 +349,9 @@ findParameters(ResultSet& foundParameters, call_sites[func_info->second].push_back(instr); } } - } + SAPFOR::buildDominatorTreeLT(bblocks); - for (auto block : bblocks) - { - if (block->getIdom() != NULL) - std::cout << "BB: " << block->getNumber() << " IDOM: " << block->getIdom()->getNumber() << std::endl; - } - std::cout << "+++++++++++\n"; } std::set alloc_statements; @@ -391,12 +365,6 @@ findParameters(ResultSet& foundParameters, } } - for (const auto& alloc_statement : alloc_statements) - { - alloc_statement->unparsestdout(); - handle_single_allocate(where_to_add, alloc_statement, fullIR); - } - set for_statements; // Find all FOR statements in the program for (const auto& [func, bblocks] : fullIR) @@ -404,39 +372,37 @@ findParameters(ResultSet& foundParameters, for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) { auto op = (*instr)->getInstruction()->getOperator(); - if (op && op->variant() == FOR_NODE) + if (op && op->variant() == FOR_NODE) for_statements.insert(op); } + for (const auto& alloc_statement : alloc_statements) + handle_single_allocate(where_to_add, alloc_statement, fullIR); + for (const auto& stmt : for_statements) - { - std::cout << string(stmt->fileName()) << ":" << stmt->lineNumber() << '\n'; handle_single_loop(where_to_add, stmt, fullIR); - } for (const auto& [stmt_before, var_name, mode] : where_to_add) { stmt_before->switchToFile(); + SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); SgVarRefExp* var = new SgVarRefExp(var_symb); SgValueExp* zero = new SgValueExp(1337); SgExprListExp* ex = new SgExprListExp(); - auto op = new SgExpression(ASSGN_OP, var, zero); - - std::cout << "len: " << ex->length() << '\n'; - ex->setLhs(new SgExpression(ASSGN_OP, var, zero)); - std::cout << "stmt_before: " << stmt_before->unparse(); + auto assgn_op = new SgExpression(ASSGN_OP, var, zero); + ex->setLhs(assgn_op); + SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex); - auto ex2 = new SgExprListExp(); - ex2->setLhs(parameter_op); - SgStatement* toAdd = new SgStatement(SPF_ANALYSIS_DIR, NULL, NULL, ex2, NULL, NULL); - toAdd->unparsestdout(); - // toAdd->lineNumber() = stmt_before->lineNumber(); + auto dir_list = new SgExprListExp(); + dir_list->setLhs(parameter_op); + SgStatement* toAdd = new SgStatement(SPF_ANALYSIS_DIR, NULL, NULL, dir_list, NULL, NULL); + toAdd->setlineNumber(stmt_before->lineNumber()); toAdd->setLocalLineNumber(stmt_before->lineNumber()); toAdd->setFileId(stmt_before->getFileId()); toAdd->setProject(stmt_before->getProject()); - stmt_before->controlParent()->unparsestdout(); + if (mode == MODE::AFTER) stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); else From d3e8c481d2da802fd587c40d06557b28525a19b3 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Fri, 30 May 2025 11:34:32 +0300 Subject: [PATCH 07/32] fixed code style, moved dom tree building to IR --- CMakeLists.txt | 2 + src/CFGraph/CFGraph.cpp | 10 ++ src/CFGraph/CFGraph.h | 23 +++- src/CFGraph/IR.h | 1 + src/CFGraph/IR_domTree.h | 35 +++++ src/ProjectParameters/domTree.h | 111 --------------- src/ProjectParameters/projectParameters.cpp | 142 +++++++++++--------- src/ProjectParameters/projectParameters.h | 38 +----- src/Sapfor.cpp | 2 - src/Utils/CommonBlock.h | 2 + src/Utils/version.h | 2 +- 11 files changed, 155 insertions(+), 213 deletions(-) create mode 100644 src/CFGraph/IR_domTree.h delete mode 100644 src/ProjectParameters/domTree.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 87eb86c..1ac1c0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,8 @@ set(TRANSFORMS set(CFG src/CFGraph/IR.cpp src/CFGraph/IR.h + src/CFGraph/IR_domTree.cpp + src/CFGraph/IR_domTree.h src/CFGraph/CFGraph.cpp src/CFGraph/CFGraph.h src/CFGraph/RD_subst.cpp diff --git a/src/CFGraph/CFGraph.cpp b/src/CFGraph/CFGraph.cpp index 4c414d4..283e0a4 100644 --- a/src/CFGraph/CFGraph.cpp +++ b/src/CFGraph/CFGraph.cpp @@ -1149,6 +1149,16 @@ map> buildCFG(const map& common if (settings.withRD) buildReachingDefs(result, settings); + if (settings.withDominators) + { + auto t = high_resolution_clock::now(); + for (auto& [func, bblocks] : result) + SAPFOR::buildDominatorTree(bblocks); + + auto msec = duration_cast(high_resolution_clock::now() - t).count(); + __spf_print(1, "dominator build time is %.3f sec\n", msec / 1000.); + } + if (SgFile::switchToFile(oldFile) == -1) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); diff --git a/src/CFGraph/CFGraph.h b/src/CFGraph/CFGraph.h index cdb190b..f0308fd 100644 --- a/src/CFGraph/CFGraph.h +++ b/src/CFGraph/CFGraph.h @@ -6,6 +6,7 @@ #include #include "IR.h" +#include "IR_domTree.h" namespace SAPFOR { @@ -24,7 +25,7 @@ namespace SAPFOR std::vector next; std::vector prev; - BasicBlock* idom{}; + BasicBlock* directDominator = NULL; //reaching definition std::map> RD_in, RD_out; @@ -34,6 +35,7 @@ namespace SAPFOR bool addLive(const std::map>& to_add, bool in); std::map> getLive(bool in) const; bool removeLive(SAPFOR::Argument* to_remove, bool in); + public: BasicBlock() { num = lastNumBlock++; } BasicBlock(IR_Block* item); @@ -42,7 +44,7 @@ namespace SAPFOR void addInstruction(IR_Block* item); void addPrev(BasicBlock* prev_) { prev.push_back(prev_); } void addNext(BasicBlock* next_) { next.push_back(next_); } - void setIdom(BasicBlock* idom_) { idom = idom_; } + void setDom(BasicBlock* dom) { directDominator = dom; } int removePrev(BasicBlock* removed); int removeNext(BasicBlock* removed); @@ -70,7 +72,16 @@ namespace SAPFOR const std::vector& getInstructions() const { return instructions; } const std::vector& getNext() const { return next; } const std::vector& getPrev() const { return prev; } - BasicBlock* getIdom() const { return idom; } + BasicBlock* getDom() const + { + if (!directDominator) + { + __spf_print(1, "%s\n", "the dominator tree was built with an error or was not built at all"); + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + } + + return directDominator; + } /* * FOR LIVE ANALYSIS @@ -107,13 +118,15 @@ namespace SAPFOR bool withDVM = false; bool withCallsInBlocks = false; // separate each F_CALL to own BasicBlock bool withCallFrom = true; + bool withDominators = true; explicit CFG_Settings(int) { } explicit CFG_Settings(bool atLeastOneIterInLoop = false, bool withRD = true, bool withRegisters = false, - bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false, bool withCallFrom = true) : + bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false, + bool withCallFrom = true, bool withDominators = true) : atLeastOneIterInLoop(atLeastOneIterInLoop), withRD(withRD), withRegisters(withRegisters), withDVM(withDVM), withSPF(withSPF), - withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom) + withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom), withDominators(withDominators) { } }; } diff --git a/src/CFGraph/IR.h b/src/CFGraph/IR.h index a887a39..d61deed 100644 --- a/src/CFGraph/IR.h +++ b/src/CFGraph/IR.h @@ -7,6 +7,7 @@ #include "CFGraph.h" #include "../Utils/CommonBlock.h" +#include "../GraphCall/graph_calls.h" namespace SAPFOR { diff --git a/src/CFGraph/IR_domTree.h b/src/CFGraph/IR_domTree.h new file mode 100644 index 0000000..78a2c8b --- /dev/null +++ b/src/CFGraph/IR_domTree.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include +#include + +#include "CFGraph.h" + +// Lengauer, Thomas. A fast algorithm for finding dominators in a flowgraph / Thomas Lengauer, Robert Endre Tarjan +// ACM Transactions on Programming Languages and Systems (TOPLAS). — 1979. — Vol. 1, no. 1. — Pp. 121–141. + +namespace SAPFOR { + +class BasicBlock; + +class DominatorFinder { +private: + BasicBlock* entry; + std::vector vertices; + std::unordered_map dfs_num; + std::vector parent, semi, vertex, ancestor, label; + std::vector> bucket; + int n; + + void DFS(BasicBlock* v, int parent_num); + void Compress(int v); + int Eval(int v); + void Link(int v, int w); + +public: + DominatorFinder(std::vector& blocks); +}; + +void buildDominatorTree(std::vector& blocks); +} diff --git a/src/ProjectParameters/domTree.h b/src/ProjectParameters/domTree.h deleted file mode 100644 index 2fe268f..0000000 --- a/src/ProjectParameters/domTree.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once - -#include "vector" -#include "map" - -#include "../CFGraph/CFGraph.h" -#include - -using namespace std; - -namespace SAPFOR { -class DominatorFinder { -private: - BasicBlock* entry; - std::vector vertices; - std::unordered_map dfs_num; - std::vector parent, semi, vertex, ancestor, label; - std::vector> bucket; - int n; - - void DFS(BasicBlock* v, int parent_num) { - dfs_num[v] = n; - vertex[n] = n; - semi[n] = n; - label[n] = n; - ancestor[n] = -1; - parent[n] = parent_num; - vertices[n++] = v; - - for (const auto& w : v->getNext()) { - if (dfs_num[w] == -1) { - DFS(w, dfs_num[v]); - } - } - } - - void Compress(int v) { - if (ancestor[ancestor[v]] != -1) { - Compress(ancestor[v]); - if (semi[label[ancestor[v]]] < semi[label[v]]) - label[v] = label[ancestor[v]]; - ancestor[v] = ancestor[ancestor[v]]; - } - } - - int Eval(int v) { - if (ancestor[v] == -1) return v; - Compress(v); - return label[v]; - } - - void Link(int v, int w) { - ancestor[w] = v; - } - -public: - DominatorFinder(std::vector& blocks) { - if (blocks.empty()) return; - entry = blocks[0]; - n = 0; - - for (auto block : blocks) dfs_num[block] = -1; - - int max_size = blocks.size(); - vertices.resize(max_size); - parent.assign(max_size, -1); - semi.assign(max_size, -1); - vertex.assign(max_size, -1); - ancestor.assign(max_size, -1); - label.assign(max_size, -1); - bucket.resize(max_size); - - DFS(entry, -1); - - for (int i = n - 1; i > 0; --i) { - int w = vertex[i]; - - for (BasicBlock* v : vertices[w]->getPrev()) { - int u = Eval(dfs_num[v]); - if (semi[u] < semi[w]) - semi[w] = semi[u]; - } - bucket[vertex[semi[w]]].push_back(w); - Link(parent[w], w); - - for (int v : bucket[parent[w]]) - { - int u = Eval(v); - if (semi[u] < semi[v]) - vertices[v]->setIdom(vertices[u]); - else - vertices[v]->setIdom(vertices[parent[w]]); - } - bucket[parent[w]].clear(); - } - - for (int i = 1; i < n; ++i) { - int w = vertex[i]; - if (vertices[w]->getIdom() != vertices[vertex[semi[w]]]) - vertices[w]->setIdom(vertices[w]->getIdom()->getIdom()); - } - - entry->setIdom(nullptr); - } -}; - -void buildDominatorTreeLT(std::vector& blocks) { - DominatorFinder finder(blocks); -} - -} diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 4bf0fec..5060983 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -18,13 +18,27 @@ #include "../GraphCall/graph_calls.h" #include "../GraphCall/graph_calls_func.h" -#include "libSage++.h" #include "projectParameters.h" -#include "domTree.h" -using namespace std; +using std::set; +using std::map; +using std::string; +using std::vector; +using std::tuple; +using std::pair; +using std::make_tuple; +using std::find_if; -tuple stmtToIR(const map>& CFGraph, SgStatement* stmt) +static map> call_sites; + +enum class MODE +{ + BEFORE, + AFTER +}; + +static tuple +stmtToIR(const map>& CFGraph, SgStatement* stmt) { SgStatement* cur = stmt; cur->switchToFile(); @@ -49,7 +63,8 @@ tuple stmtToIR(const map IRByNumber(const map>& CFGraph, int num) +static tuple +IRByNumber(const map>& CFGraph, int num) { if (num < 0) return { NULL, NULL, NULL }; @@ -60,30 +75,27 @@ tuple IRByNumber(const map return make_tuple(func, getInstructionByNumber(byBB->getInstructions(), num), byBB); printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - return { NULL, NULL, NULL}; + return { NULL, NULL, NULL }; } template -void processArgument(set& worklist, - SAPFOR::Argument* arg, - Iterator instr, - Iterator first_instr) +static void processArgument(set& worklist, + SAPFOR::Argument* arg, + Iterator instr, Iterator first_instr) { if (arg == NULL) return; + if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG) extract_vars_from_reg(worklist, arg, instr, first_instr); else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR) - { worklist.insert(arg); - } } template -void extract_vars_from_reg(set& worklist, - SAPFOR::Argument* reg, - Iterator instr, - Iterator first_instr) +static void extract_vars_from_reg(set& worklist, + SAPFOR::Argument* reg, + Iterator instr, Iterator first_instr) { for (; instr >= first_instr; instr--) { @@ -96,21 +108,21 @@ void extract_vars_from_reg(set& worklist, } } -void lookup_for_vars(std::set>& where_to_add, - set& worklist, - SAPFOR::Instruction* instr, - SAPFOR::BasicBlock* bblock, - FuncInfo* cur_func, - const std::map>& fullIR) +static void lookup_for_vars(set>& where_to_add, + set& worklist, + SAPFOR::Instruction* instr, + SAPFOR::BasicBlock* bblock, + FuncInfo* cur_func, + const map>& fullIR) { while (bblock) { auto first_instr = bblock->getInstructions().begin(); - auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { + auto cur_instr = find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { return i->getInstruction() == instr; - }); + }); - for (; cur_instr >= bblock->getInstructions().begin(); cur_instr--) + for (; cur_instr >= bblock->getInstructions().begin(); --cur_instr) { auto instr = (*cur_instr)->getInstruction(); auto result_arg = instr->getResult(); @@ -123,6 +135,7 @@ void lookup_for_vars(std::set>& wher processArgument(worklist, arg2, cur_instr, first_instr); worklist.erase(result_arg); } + if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) { // skip to F_CALL @@ -136,7 +149,7 @@ void lookup_for_vars(std::set>& wher auto filename = stmt_before->fileName(); auto line = stmt_before->lineNumber(); auto var_name = arg1->getValue().substr(arg1->getValue().find('%') + 1); - __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg1->getValue().c_str(), line, filename); + __spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg1->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_before, var_name, MODE::AFTER); where_to_add.insert(toAdd); worklist.erase(arg1); @@ -159,7 +172,7 @@ void lookup_for_vars(std::set>& wher auto line = stmt_after->lineNumber(); auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1); __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str()); - __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); + __spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); where_to_add.insert(toAdd); worklist.erase(arg); @@ -175,7 +188,8 @@ void lookup_for_vars(std::set>& wher } while (bblock && group_by_block.find(bblock) == group_by_block.end()) - bblock = bblock->getIdom(); + bblock = bblock->getDom(); + if (bblock) instr = group_by_block[bblock]; } @@ -189,6 +203,7 @@ void lookup_for_vars(std::set>& wher set found_rd; if (RD.count(arg)) found_rd = RD.at(arg); + if (found_rd.size() == 0) { auto call_instr = call_sites[cur_func].size() ? call_sites[cur_func].front() : NULL; @@ -202,10 +217,10 @@ void lookup_for_vars(std::set>& wher call_instr = call_sites[call_func].size() ? call_sites[call_func].front() : NULL; } } + if (found_rd.size() == 1 && *found_rd.begin() == SAPFOR::CFG_VAL::UNINIT) - { __spf_print(1, "variable %s has no definition\n", arg->getValue().c_str()); - } else if (found_rd.size() > 1) + else if (found_rd.size() > 1) { auto first_instr = fullIR.at(cur_func).front()->getInstructions().begin(); auto stmt_after = (*first_instr)->getInstruction()->getOperator(); @@ -213,7 +228,7 @@ void lookup_for_vars(std::set>& wher auto line = stmt_after->lineNumber(); auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1); __spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str()); - __spf_print(1,"Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); + __spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); where_to_add.insert(toAdd); } @@ -221,7 +236,7 @@ void lookup_for_vars(std::set>& wher { auto instr_num = *found_rd.begin(); auto [func, instr, bblock] = IRByNumber(fullIR, instr_num); - set new_worklist = {arg}; + set new_worklist = { arg }; lookup_for_vars(where_to_add, new_worklist, instr, bblock, func, fullIR); } @@ -236,14 +251,15 @@ void lookup_for_vars(std::set>& wher auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber()); auto first_instr = call_bblock->getInstructions().begin(); - auto cur_instr = std::find_if(first_instr, call_bblock->getInstructions().end(), [call_instr](SAPFOR::IR_Block* i) { + auto cur_instr = find_if(first_instr, call_bblock->getInstructions().end(), [call_instr](SAPFOR::IR_Block* i) { return i->getInstruction() == call_instr; - }); + }); + for (auto& arg : worklist) { if (arg->getMemType() == SAPFOR::CFG_MEM_TYPE::FUNC_PARAM_) { - auto param_num= stoi(arg->getValue().substr(arg->getValue().find('%', arg->getValue().find('%') + 1) + 1)); + auto param_num = stoi(arg->getValue().substr(arg->getValue().find('%', arg->getValue().find('%') + 1) + 1)); auto param_instr = (cur_instr - (params_num - param_num)); auto param_arg = (*param_instr)->getInstruction()->getArg1(); processArgument(new_worklist, param_arg, param_instr, first_instr); @@ -254,24 +270,23 @@ void lookup_for_vars(std::set>& wher } -void handle_single_allocate(std::set>& where_to_add, - SgStatement* alloc_statement, - const std::map>& fullIR) +static void handle_single_allocate(set>& where_to_add, + SgStatement* alloc_statement, + const map>& fullIR) { auto [func, instr, bblock] = stmtToIR(fullIR, alloc_statement); auto first_instr = bblock->getInstructions().begin(); - auto cur_instr = std::find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { + auto cur_instr = find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) { return i->getInstruction() == instr; - }); + }); auto alloc_instr = cur_instr; // skip to F_CALL _ALLOC n while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL || - (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") + (*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC") alloc_instr++; - auto arrays_num = stoi((*alloc_instr)->getInstruction()->getArg2()->getValue()); set worklist; @@ -281,7 +296,7 @@ void handle_single_allocate(std::set>& wh auto param_reg = (*param_instr)->getInstruction()->getArg1(); while ((*param_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::LOAD || - (*param_instr)->getInstruction()->getResult() != param_reg) + (*param_instr)->getInstruction()->getResult() != param_reg) param_instr--; @@ -292,29 +307,29 @@ void handle_single_allocate(std::set>& wh auto ref_instr = --param_instr; if ((*ref_instr)->getInstruction()->getOperation() == SAPFOR::CFG_OP::RANGE) { - vector range_args = {(*ref_instr)->getInstruction()->getArg1(), + vector range_args = { (*ref_instr)->getInstruction()->getArg1(), (*ref_instr)->getInstruction()->getArg2(), - (*ref_instr)->getInstruction()->getResult()}; + (*ref_instr)->getInstruction()->getResult() }; for (auto& arg : range_args) processArgument(worklist, arg, ref_instr, first_instr); - } else + } + else { auto arg = (*ref_instr)->getInstruction()->getArg1(); processArgument(worklist, arg, ref_instr, first_instr); } } } - lookup_for_vars(where_to_add,worklist, instr, bblock, func, fullIR); + lookup_for_vars(where_to_add, worklist, instr, bblock, func, fullIR); } -void handle_single_loop(std::set>& where_to_add, - SgStatement* loop_stmt, - const std::map>& fullIR) +static void handle_single_loop(set>& where_to_add, + SgStatement* loop_stmt, + const map>& fullIR) { auto [func, instr, bblock] = stmtToIR(fullIR, loop_stmt); - auto cur_instr = bblock->getInstructions().end() - 1; set worklist; @@ -323,10 +338,9 @@ void handle_single_loop(std::set>& where_ lookup_for_vars(where_to_add, worklist, (*cur_instr)->getInstruction(), bblock, func, fullIR); } -void -findParameters(ResultSet& foundParameters, - std::map>& fullIR, - const std::map, std::pair>& declaredArrays) +void findParameters(ResultSet& foundParameters, + map>& fullIR, + const map, pair>& declaredArrays) { set> where_to_add; @@ -337,6 +351,7 @@ findParameters(ResultSet& foundParameters, for (auto& [func, bblocks] : fullIR) { for (const auto& block : bblocks) + { for (const auto& ir_block : block->getInstructions()) { auto instr = ir_block->getInstruction(); @@ -349,32 +364,37 @@ findParameters(ResultSet& foundParameters, call_sites[func_info->second].push_back(instr); } } - - - SAPFOR::buildDominatorTreeLT(bblocks); + } } - std::set alloc_statements; + set alloc_statements; for (const auto& [func, bblocks] : fullIR) + { for (const auto& block : bblocks) + { for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) { auto op = (*instr)->getInstruction()->getOperator(); - if (op && op->variant() == ALLOCATE_STMT) { + if (op && op->variant() == ALLOCATE_STMT) alloc_statements.insert(op); - } } + } + } set for_statements; // Find all FOR statements in the program for (const auto& [func, bblocks] : fullIR) + { for (const auto& block : bblocks) + { for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr) { auto op = (*instr)->getInstruction()->getOperator(); if (op && op->variant() == FOR_NODE) for_statements.insert(op); } + } + } for (const auto& alloc_statement : alloc_statements) handle_single_allocate(where_to_add, alloc_statement, fullIR); diff --git a/src/ProjectParameters/projectParameters.h b/src/ProjectParameters/projectParameters.h index 1181560..83a69e3 100644 --- a/src/ProjectParameters/projectParameters.h +++ b/src/ProjectParameters/projectParameters.h @@ -1,42 +1,14 @@ #pragma once -#include "libSage++.h" #include #include #include #include +#include "..\GraphCall\graph_calls.h" + using ResultSet = std::set>; -enum class MODE -{ - BEFORE, - AFTER -}; - -static std::map> call_sites; - -template -void extract_vars_from_reg(std::set& worklist, - SAPFOR::Argument* reg, - Iterator instr, - Iterator first_instr); - - -template -void processArgument(std::set& worklist, - SAPFOR::Argument* arg, - Iterator instr, - Iterator first_instr); - -void lookup_for_vars(std::set>& where_to_add, - std::set& worklist, - SAPFOR::Instruction* instr, - SAPFOR::BasicBlock* bblock, - FuncInfo* cur_func, - const std::map>& fullIR); - -void -findParameters(ResultSet& foundParameters, - std::map>& fullIR, - const std::map, std::pair>& declaredArrays); +void findParameters(ResultSet& foundParameters, + std::map>& fullIR, + const std::map, std::pair>& declaredArrays); diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 2bee6a5..e604e39 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -1894,9 +1894,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == RENAME_SYMBOLS) runRenameSymbols(&project, commonBlocks); else if (curr_regime == FIND_PARAMETERS) - { findParameters(parametersOfProject, fullIR, declaredArrays); - } else if (curr_regime == BUILD_IR) { auto CFG_forFile = buildCFG(commonBlocks, allFuncInfo_IR, SAPFOR::CFG_Settings(0)); diff --git a/src/Utils/CommonBlock.h b/src/Utils/CommonBlock.h index 196f3b9..7b89792 100644 --- a/src/Utils/CommonBlock.h +++ b/src/Utils/CommonBlock.h @@ -1,5 +1,7 @@ #pragma once +#include "../Distribution/Array.h" + enum varType { SCALAR, ARRAY, CONST, ANOTHER }; struct CommonVariableUse diff --git a/src/Utils/version.h b/src/Utils/version.h index 43758a9..6f49767 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2422" +#define VERSION_SPF "2423" From ad99446b129d60641d8af81815cd7eb269bf7778 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Fri, 30 May 2025 11:57:39 +0300 Subject: [PATCH 08/32] added missing --- src/CFGraph/IR_domTree.cpp | 100 +++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/CFGraph/IR_domTree.cpp diff --git a/src/CFGraph/IR_domTree.cpp b/src/CFGraph/IR_domTree.cpp new file mode 100644 index 0000000..cfab670 --- /dev/null +++ b/src/CFGraph/IR_domTree.cpp @@ -0,0 +1,100 @@ +#include "dvm.h" +#include "IR_domTree.h" + +namespace SAPFOR { + void DominatorFinder::DFS(BasicBlock* v, int parent_num) { + dfs_num[v] = n; + vertex[n] = n; + semi[n] = n; + label[n] = n; + ancestor[n] = -1; + parent[n] = parent_num; + vertices[n++] = v; + + for (const auto& w : v->getNext()) { + if (dfs_num[w] == -1) + DFS(w, dfs_num[v]); + } + } + + void DominatorFinder::Compress(int v) { + if (ancestor[ancestor[v]] != -1) { + Compress(ancestor[v]); + + if (semi[label[ancestor[v]]] < semi[label[v]]) + label[v] = label[ancestor[v]]; + ancestor[v] = ancestor[ancestor[v]]; + } + } + + int DominatorFinder::Eval(int v) { + if (ancestor[v] == -1) + return v; + + Compress(v); + return label[v]; + } + + void DominatorFinder::Link(int v, int w) { + ancestor[w] = v; + } + + DominatorFinder::DominatorFinder(std::vector& blocks) { + if (blocks.empty()) + return; + + entry = blocks[0]; + n = 0; + + for (auto block : blocks) + dfs_num[block] = -1; + + int max_size = blocks.size(); + vertices.resize(max_size); + parent.assign(max_size, -1); + semi.assign(max_size, -1); + vertex.assign(max_size, -1); + ancestor.assign(max_size, -1); + label.assign(max_size, -1); + bucket.resize(max_size); + + DFS(entry, -1); + + for (int i = n - 1; i > 0; --i) { + int w = vertex[i]; + + for (BasicBlock* v : vertices[w]->getPrev()) { + int u = Eval(dfs_num[v]); + + if (semi[u] < semi[w]) + semi[w] = semi[u]; + } + + bucket[vertex[semi[w]]].push_back(w); + Link(parent[w], w); + + for (int v : bucket[parent[w]]) + { + int u = Eval(v); + if (semi[u] < semi[v]) + vertices[v]->setDom(vertices[u]); + else + vertices[v]->setDom(vertices[parent[w]]); + } + bucket[parent[w]].clear(); + } + + for (int i = 1; i < n; ++i) { + int w = vertex[i]; + + if (vertices[w]->getDom() != vertices[vertex[semi[w]]]) + vertices[w]->setDom(vertices[w]->getDom()->getDom()); + } + + entry->setDom(nullptr); + } + + void buildDominatorTree(std::vector& blocks) { + DominatorFinder finder(blocks); + } +} \ No newline at end of file From b454858647a9f6f8b90cbe06dc424dfc22b64dec Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Thu, 1 May 2025 19:48:47 +0300 Subject: [PATCH 09/32] delete zero from directive --- src/ProjectParameters/projectParameters.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 5060983..af7c038 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -408,9 +408,8 @@ void findParameters(ResultSet& foundParameters, SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str()); SgVarRefExp* var = new SgVarRefExp(var_symb); - SgValueExp* zero = new SgValueExp(1337); SgExprListExp* ex = new SgExprListExp(); - auto assgn_op = new SgExpression(ASSGN_OP, var, zero); + auto assgn_op = new SgExpression(ASSGN_OP, var, NULL); ex->setLhs(assgn_op); SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex); From a2e6269508b7682c5fe9dbc163bff030557d8d33 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 2 Jun 2025 08:23:40 +0300 Subject: [PATCH 10/32] fix range stuctures --- src/PrivateAnalyzer/range_structures.cpp | 3 ++- src/PrivateAnalyzer/region.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PrivateAnalyzer/range_structures.cpp b/src/PrivateAnalyzer/range_structures.cpp index 9a2f437..75f2779 100644 --- a/src/PrivateAnalyzer/range_structures.cpp +++ b/src/PrivateAnalyzer/range_structures.cpp @@ -184,7 +184,8 @@ void AccessingSet::FindUncovered(const vector& element, vectorsetHeader(bbToRegion.at(header)); else + { + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); return NULL; + } for (SAPFOR::BasicBlock* block : blockSet) if (bbToRegion.find(block) != bbToRegion.end()) @@ -223,7 +229,6 @@ static Region* CreateSubRegion(LoopGraph* loop, const vectorchildren) region->addSubRegions(CreateSubRegion(childLoop, Blocks, bbToRegion)); - cout << header << endl; return region; } From a0a401c42acba29e8c8fbcaaa7be21f011fa9578 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Mon, 2 Jun 2025 19:08:09 +0300 Subject: [PATCH 11/32] refactored transformation: added folders for each transformation --- CMakeLists.txt | 107 +++++++++--------- src/CFGraph/CFGraph.cpp | 4 +- src/CFGraph/IR.cpp | 6 +- src/CFGraph/RD_subst.cpp | 4 +- src/CFGraph/RD_subst.h | 2 +- .../directive_analyzer.cpp | 2 +- src/DirectiveProcessing/directive_creator.cpp | 6 +- .../directive_creator_base.cpp | 4 +- .../directive_omp_parser.cpp | 2 +- src/DirectiveProcessing/directive_parser.cpp | 2 +- src/DirectiveProcessing/insert_directive.cpp | 2 +- src/DirectiveProcessing/remote_access.cpp | 4 +- .../remote_access_base.cpp | 4 +- src/DirectiveProcessing/shadow.cpp | 6 +- .../spf_directive_preproc.cpp | 4 +- src/Distribution/Array.cpp | 2 +- src/Distribution/ArrayAnalysis.cpp | 2 +- src/Distribution/CreateDistributionDirs.cpp | 2 +- src/Distribution/Cycle.cpp | 2 +- src/Distribution/Distribution.cpp | 2 +- src/Distribution/DvmhDirective.cpp | 2 +- src/Distribution/DvmhDirectiveBase.cpp | 2 +- src/Distribution/GraphCSR.cpp | 2 +- src/DvmhRegions/DvmhRegionInserter.cpp | 2 +- src/DvmhRegions/DvmhRegionInserter.h | 2 +- src/DynamicAnalysis/createParallelRegions.cpp | 4 +- src/DynamicAnalysis/createParallelRegions.h | 2 +- src/DynamicAnalysis/gCov_parser.cpp | 2 +- src/DynamicAnalysis/gcov_info.cpp | 2 +- src/GraphCall/graph_calls.cpp | 4 +- src/GraphCall/graph_calls_base.cpp | 2 +- src/GraphLoop/graph_loops.cpp | 6 +- src/GraphLoop/graph_loops_base.cpp | 2 +- src/LoopAnalyzer/allocations_prepoc.cpp | 2 +- src/LoopAnalyzer/dep_analyzer.cpp | 2 +- src/LoopAnalyzer/loop_analyzer.cpp | 6 +- src/LoopAnalyzer/loop_analyzer.h | 2 +- src/ParallelizationRegions/ParRegions.cpp | 4 +- src/ParallelizationRegions/ParRegions_func.h | 2 +- .../expand_extract_reg.cpp | 2 +- .../resolve_par_reg_conflicts.cpp | 6 +- .../resolve_par_reg_conflicts.h | 2 +- src/Predictor/PredictScheme.cpp | 4 +- src/Predictor/PredictScheme.h | 2 +- src/PrivateAnalyzer/private_analyzer.cpp | 4 +- src/PrivateAnalyzer/private_analyzer.h | 2 +- src/ProjectManipulation/ConvertFiles.cpp | 2 +- src/ProjectManipulation/FileInfo.cpp | 2 +- src/ProjectManipulation/ParseFiles.cpp | 2 +- src/ProjectManipulation/PerfAnalyzer.cpp | 2 +- src/ProjectParameters/projectParameters.cpp | 4 +- src/SageAnalysisTool/defUse.cpp | 2 +- src/SageAnalysisTool/depGraph.cpp | 2 +- src/Sapfor.cpp | 42 ++++--- .../swap_array_dims.cpp | 0 .../{ => ArrayDimsSwapping}/swap_array_dims.h | 0 .../{ => CheckPoints}/checkpoints.cpp | 4 +- .../{ => CheckPoints}/checkpoints.h | 0 .../{ => ConvertToC}/convert_to_c.cpp | 2 +- .../{ => ConvertToC}/convert_to_c.h | 0 .../{ => DeadCodeRemoving}/dead_code.cpp | 0 .../{ => DeadCodeRemoving}/dead_code.h | 0 .../control_flow_graph_part.cpp | 2 +- .../expr_transform.cpp | 4 +- .../ExpressionSubstitution}/expr_transform.h | 2 +- .../uniq_call_chain_dup.cpp | 6 +- .../uniq_call_chain_dup.h | 2 +- .../FunctionInlining}/inliner.cpp | 4 +- .../FunctionInlining}/inliner.h | 0 .../function_purifying.cpp | 4 +- .../function_purifying.h | 0 .../fix_common_blocks.cpp | 0 .../{ => GlobalVariables}/fix_common_blocks.h | 2 +- .../{ => LoopCombining}/loops_combiner.cpp | 2 +- .../{ => LoopCombining}/loops_combiner.h | 0 .../enddo_loop_converter.cpp | 2 +- .../enddo_loop_converter.h | 0 .../{ => LoopNesting}/loop_transform.cpp | 2 +- .../{ => LoopNesting}/loop_transform.h | 0 .../{ => LoopSplitting}/loops_splitter.cpp | 2 +- .../{ => LoopSplitting}/loops_splitter.h | 0 .../{ => LoopUnrolling}/loops_unrolling.cpp | 0 .../{ => LoopUnrolling}/loops_unrolling.h | 0 .../private_removing.cpp | 4 +- .../private_removing.h | 0 .../private_arrays_resizing.cpp | 0 .../private_arrays_resizing.h | 0 .../RenameSymbols/rename_symbols.cpp | 2 +- .../RenameSymbols/rename_symbols.h | 0 .../replace_dist_arrays_in_io.cpp | 6 +- .../replace_dist_arrays_in_io.h | 2 +- .../set_implicit_none.cpp | 2 +- .../{ => SetImplicitNone}/set_implicit_none.h | 0 .../array_assign_to_loop.cpp | 4 +- .../array_assign_to_loop.h | 0 src/Utils/SgUtils.cpp | 4 +- src/Utils/SgUtils.h | 2 +- src/Utils/utils.cpp | 2 +- src/VerificationCode/CorrectVarDecl.cpp | 2 +- src/VerificationCode/IncludeChecker.cpp | 2 +- src/VerificationCode/StructureChecker.cpp | 2 +- src/VerificationCode/VerifySageStructures.cpp | 2 +- 102 files changed, 189 insertions(+), 188 deletions(-) rename src/Transformations/{ => ArrayDimsSwapping}/swap_array_dims.cpp (100%) rename src/Transformations/{ => ArrayDimsSwapping}/swap_array_dims.h (100%) rename src/Transformations/{ => CheckPoints}/checkpoints.cpp (97%) rename src/Transformations/{ => CheckPoints}/checkpoints.h (100%) rename src/Transformations/{ => ConvertToC}/convert_to_c.cpp (96%) rename src/Transformations/{ => ConvertToC}/convert_to_c.h (100%) rename src/Transformations/{ => DeadCodeRemoving}/dead_code.cpp (100%) rename src/Transformations/{ => DeadCodeRemoving}/dead_code.h (100%) rename src/{ExpressionTransform => Transformations/ExpressionSubstitution}/control_flow_graph_part.cpp (96%) rename src/{ExpressionTransform => Transformations/ExpressionSubstitution}/expr_transform.cpp (96%) rename src/{ExpressionTransform => Transformations/ExpressionSubstitution}/expr_transform.h (96%) rename src/Transformations/{ => FunctionDuplication}/uniq_call_chain_dup.cpp (96%) rename src/Transformations/{ => FunctionDuplication}/uniq_call_chain_dup.h (89%) rename src/{Inliner => Transformations/FunctionInlining}/inliner.cpp (97%) rename src/{Inliner => Transformations/FunctionInlining}/inliner.h (100%) rename src/Transformations/{ => FunctionPurifying}/function_purifying.cpp (97%) rename src/Transformations/{ => FunctionPurifying}/function_purifying.h (100%) rename src/Transformations/{ => GlobalVariables}/fix_common_blocks.cpp (100%) rename src/Transformations/{ => GlobalVariables}/fix_common_blocks.h (93%) rename src/Transformations/{ => LoopCombining}/loops_combiner.cpp (96%) rename src/Transformations/{ => LoopCombining}/loops_combiner.h (100%) rename src/Transformations/{ => LoopEndDoConverter}/enddo_loop_converter.cpp (96%) rename src/Transformations/{ => LoopEndDoConverter}/enddo_loop_converter.h (100%) rename src/Transformations/{ => LoopNesting}/loop_transform.cpp (96%) rename src/Transformations/{ => LoopNesting}/loop_transform.h (100%) rename src/Transformations/{ => LoopSplitting}/loops_splitter.cpp (97%) rename src/Transformations/{ => LoopSplitting}/loops_splitter.h (100%) rename src/Transformations/{ => LoopUnrolling}/loops_unrolling.cpp (100%) rename src/Transformations/{ => LoopUnrolling}/loops_unrolling.h (100%) rename src/Transformations/{ => PrivateArrayRemoving}/private_removing.cpp (97%) rename src/Transformations/{ => PrivateArrayRemoving}/private_removing.h (100%) rename src/Transformations/{ => PrivateArrayResizing}/private_arrays_resizing.cpp (100%) rename src/Transformations/{ => PrivateArrayResizing}/private_arrays_resizing.h (100%) rename src/{ => Transformations}/RenameSymbols/rename_symbols.cpp (96%) rename src/{ => Transformations}/RenameSymbols/rename_symbols.h (100%) rename src/Transformations/{ => ReplaceArraysInIO}/replace_dist_arrays_in_io.cpp (96%) rename src/Transformations/{ => ReplaceArraysInIO}/replace_dist_arrays_in_io.h (91%) rename src/Transformations/{ => SetImplicitNone}/set_implicit_none.cpp (96%) rename src/Transformations/{ => SetImplicitNone}/set_implicit_none.h (100%) rename src/Transformations/{ => VectorAssignToLoop}/array_assign_to_loop.cpp (97%) rename src/Transformations/{ => VectorAssignToLoop}/array_assign_to_loop.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 145d672..ba85c74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,13 @@ set(libpred_sources projects/libpredictor/src/) set(libpred_include projects/libpredictor/include/) include_directories(src) +include_directories(src/Utils) +include_directories(src/SgUtils) +include_directories(src/Distribution) +include_directories(src/GraphCall) +include_directories(src/GraphLoop) +include_directories(src/Transformations/ExpressionSubstitution) + #Sage lib includes include_directories(${fdvm_include}) include_directories(${sage_include_1}) @@ -154,40 +161,47 @@ set(PARALLEL_REG src/ParallelizationRegions/ParRegions.cpp src/ParallelizationRegions/resolve_par_reg_conflicts.cpp src/ParallelizationRegions/resolve_par_reg_conflicts.h) -set(TR_DEAD_CODE src/Transformations/dead_code.cpp - src/Transformations/dead_code.h) -set(TR_CP src/Transformations/checkpoints.cpp - src/Transformations/checkpoints.h) -set(TR_VECTOR src/Transformations/array_assign_to_loop.cpp - src/Transformations/array_assign_to_loop.h) -set(TR_ENDDO_LOOP src/Transformations/enddo_loop_converter.cpp - src/Transformations/enddo_loop_converter.h) -set(TR_LOOP_NEST src/Transformations/loop_transform.cpp - src/Transformations/loop_transform.h) -set(TR_LOOP_COMB src/Transformations/loops_combiner.cpp - src/Transformations/loops_combiner.h) -set(TR_LOOP_SPLIT src/Transformations/loops_splitter.cpp - src/Transformations/loops_splitter.h) -set(TR_LOOP_UNROLL src/Transformations/loops_unrolling.cpp - src/Transformations/loops_unrolling.h) -set(TR_PRIV_BR src/Transformations/private_arrays_resizing.cpp - src/Transformations/private_arrays_resizing.h) -set(TR_PRIV_DEL src/Transformations/private_removing.cpp - src/Transformations/private_removing.h) -set(TR_SWAP_ARR_DIMS src/Transformations/swap_array_dims.cpp - src/Transformations/swap_array_dims.h) -set(TR_FUNC_DUP src/Transformations/uniq_call_chain_dup.cpp - src/Transformations/uniq_call_chain_dup.h) -set(TR_FUNC_PURE src/Transformations/function_purifying.cpp - src/Transformations/function_purifying.h) -set(TR_GV src/Transformations/fix_common_blocks.cpp - src/Transformations/fix_common_blocks.h) -set(TR_CONV src/Transformations/convert_to_c.cpp - src/Transformations/convert_to_c.h) -set(TR_IMPLICIT_NONE src/Transformations/set_implicit_none.cpp - src/Transformations/set_implicit_none.h) -set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/replace_dist_arrays_in_io.cpp - src/Transformations/replace_dist_arrays_in_io.h) +set(TR_DEAD_CODE src/Transformations/DeadCodeRemoving/dead_code.cpp + src/Transformations/DeadCodeRemoving/dead_code.h) +set(TR_CP src/Transformations/CheckPoints/checkpoints.cpp + src/Transformations/CheckPoints/checkpoints.h) +set(TR_VECTOR src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp + src/Transformations/VectorAssignToLoop/array_assign_to_loop.h) +set(TR_ENDDO_LOOP src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp + src/Transformations/LoopEndDoConverter/enddo_loop_converter.h) +set(TR_LOOP_NEST src/Transformations/LoopNesting/loop_transform.cpp + src/Transformations/LoopNesting/loop_transform.h) +set(TR_LOOP_COMB src/Transformations/LoopCombining/loops_combiner.cpp + src/Transformations/LoopCombining/loops_combiner.h) +set(TR_LOOP_SPLIT src/Transformations/LoopSplitting/loops_splitter.cpp + src/Transformations/LoopSplitting/loops_splitter.h) +set(TR_LOOP_UNROLL src/Transformations/LoopUnrolling/loops_unrolling.cpp + src/Transformations/LoopUnrolling/loops_unrolling.h) +set(TR_PRIV_BR src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp + src/Transformations/PrivateArrayResizing/private_arrays_resizing.h) +set(TR_PRIV_DEL src/Transformations/PrivateArrayRemoving/private_removing.cpp + src/Transformations/PrivateArrayRemoving/private_removing.h) +set(TR_SWAP_ARR_DIMS src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp + src/Transformations/ArrayDimsSwapping/swap_array_dims.h) +set(TR_FUNC_DUP src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp + src/Transformations/FunctionDuplication/uniq_call_chain_dup.h) +set(TR_FUNC_PURE src/Transformations/FunctionPurifying/function_purifying.cpp + src/Transformations/FunctionPurifying/function_purifying.h) +set(TR_GV src/Transformations/GlobalVariables/fix_common_blocks.cpp + src/Transformations/GlobalVariables/fix_common_blocks.h) +set(TR_CONV src/Transformations/ConvertToC/convert_to_c.cpp + src/Transformations/ConvertToC/convert_to_c.h) +set(TR_IMPLICIT_NONE src/Transformations/SetImplicitNone/set_implicit_none.cpp + src/Transformations/SetImplicitNone/set_implicit_none.h) +set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp + src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h) +set(TR_EXPR_TRANSFORM src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp + src/Transformations/ExpressionSubstitution/expr_transform.cpp + src/Transformations/ExpressionSubstitution/expr_transform.h) +set(TR_INLINER src/Transformations/FunctionInlining/inliner.cpp + src/Transformations/FunctionInlining/inliner.h) +set(TR_RENAME_SYMBOLS src/Transformations/RenameSymbols/rename_symbols.cpp + src/Transformations/RenameSymbols/rename_symbols.h) set(TRANSFORMS ${TR_DEAD_CODE} @@ -207,7 +221,10 @@ set(TRANSFORMS ${TR_CONV} ${TR_PRIV_DEL} ${TR_IMPLICIT_NONE} - ${TR_REPLACE_ARRAYS_IN_IO}) + ${TR_REPLACE_ARRAYS_IN_IO} + ${TR_EXPR_TRANSFORM} + ${TR_INLINER} + ${TR_RENAME_SYMBOLS}) set(CFG src/CFGraph/IR.cpp src/CFGraph/IR.h @@ -288,10 +305,6 @@ set(DYNA src/DynamicAnalysis/createParallelRegions.cpp src/DynamicAnalysis/gcov_info.h src/DynamicAnalysis/gCov_parser.cpp src/DynamicAnalysis/gCov_parser_func.h) - -set(EXPR_TRANSFORM src/ExpressionTransform/control_flow_graph_part.cpp - src/ExpressionTransform/expr_transform.cpp - src/ExpressionTransform/expr_transform.h) set(GR_CALL src/GraphCall/graph_calls.cpp src/GraphCall/graph_calls.h @@ -303,18 +316,11 @@ set(GR_LOOP src/GraphLoop/graph_loops_base.cpp src/GraphLoop/graph_loops.h src/GraphLoop/graph_loops_func.h) -set(INLINER src/Inliner/inliner.cpp - src/Inliner/inliner.h) - set(LOOP_ANALYZER src/LoopAnalyzer/allocations_prepoc.cpp src/LoopAnalyzer/dep_analyzer.cpp src/LoopAnalyzer/loop_analyzer.cpp src/LoopAnalyzer/loop_analyzer.h) -set(RENAME_SYMBOLS src/RenameSymbols/rename_symbols.cpp - src/RenameSymbols/rename_symbols.h) - - set(MAIN src/Sapfor.cpp src/Sapfor.h src/SapforData.h @@ -404,12 +410,9 @@ set(SOURCE_EXE ${DISTR} ${DVMH_REG} ${DYNA} - ${EXPR_TRANSFORM} ${GR_CALL} ${GR_LOOP} - ${INLINER} ${LOOP_ANALYZER} - ${RENAME_SYMBOLS} ${TRANSFORMS} ${PARALLEL_REG} ${PRIV} @@ -433,7 +436,7 @@ source_group (CFGraph FILES ${CFG}) source_group (CFGraph\\DataFlow FILES ${DATA_FLOW}) source_group (Transformations\\DeadCodeRemoving FILES ${TR_DEAD_CODE}) -source_group (Transformations\\ExpressionSubstitution FILES ${EXPR_TRANSFORM}) +source_group (Transformations\\ExpressionSubstitution FILES ${TR_EXPR_TRANSFORM}) source_group (Transformations\\CheckPoints FILES ${TR_CP}) source_group (Transformations\\LoopEndDoConverter FILES ${TR_ENDDO_LOOP}) source_group (Transformations\\LoopNesting FILES ${TR_LOOP_NEST}) @@ -441,13 +444,13 @@ source_group (Transformations\\LoopCombining FILES ${TR_LOOP_COMB}) source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT}) source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL}) source_group (Transformations\\FunctionDuplication FILES ${TR_FUNC_DUP}) -source_group (Transformations\\FunctionInlining FILES ${INLINER}) +source_group (Transformations\\FunctionInlining FILES ${TR_INLINER}) source_group (Transformations\\FunctionPurifying FILES ${TR_FUNC_PURE}) source_group (Transformations\\ArrayDimsSwapping FILES ${TR_SWAP_ARR_DIMS}) source_group (Transformations\\PrivateArrayResizing FILES ${TR_PRIV_BR}) source_group (Transformations\\PrivateArrayRemoving FILES ${TR_PRIV_DEL}) source_group (Transformations\\VectorAssignToLoop FILES ${TR_VECTOR}) -source_group (Transformations\\RenameSymbols FILES ${RENAME_SYMBOLS}) +source_group (Transformations\\RenameSymbols FILES ${TR_RENAME_SYMBOLS}) source_group (Transformations\\GlobalVariables FILES ${TR_GV}) source_group (Transformations\\ConvertToC FILES ${TR_CONV}) source_group (Transformations\\SetImplicitNone FILES ${TR_IMPLICIT_NONE}) diff --git a/src/CFGraph/CFGraph.cpp b/src/CFGraph/CFGraph.cpp index 4c414d4..56af300 100644 --- a/src/CFGraph/CFGraph.cpp +++ b/src/CFGraph/CFGraph.cpp @@ -1,5 +1,5 @@ #define _LEAK_ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -10,7 +10,7 @@ #include "../Utils/SgUtils.h" #include "../Utils/CommonBlock.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "dvm.h" #include "IR.h" diff --git a/src/CFGraph/IR.cpp b/src/CFGraph/IR.cpp index a46226b..9c110f8 100644 --- a/src/CFGraph/IR.cpp +++ b/src/CFGraph/IR.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -7,8 +7,8 @@ #include "../Utils/SgUtils.h" #include "../Utils/CommonBlock.h" -#include "../GraphCall/graph_calls.h" -#include "../ExpressionTransform/expr_transform.h" +#include "graph_calls.h" +#include "expr_transform.h" #include "dvm.h" #include "IR.h" diff --git a/src/CFGraph/RD_subst.cpp b/src/CFGraph/RD_subst.cpp index 948fb97..4f48deb 100644 --- a/src/CFGraph/RD_subst.cpp +++ b/src/CFGraph/RD_subst.cpp @@ -10,8 +10,8 @@ #include "../Utils/SgUtils.h" #include "../Utils/CommonBlock.h" -#include "../GraphCall/graph_calls.h" -#include "../ExpressionTransform/expr_transform.h" +#include "graph_calls.h" +#include "expr_transform.h" #define PRINT_PROF_INFO 0 #define DEBUG_CHECKS 0 diff --git a/src/CFGraph/RD_subst.h b/src/CFGraph/RD_subst.h index 188effb..d9e4143 100644 --- a/src/CFGraph/RD_subst.h +++ b/src/CFGraph/RD_subst.h @@ -4,7 +4,7 @@ #include "../Utils/SgUtils.h" #include "../Utils/CommonBlock.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "CFGraph.h" #include "IR.h" diff --git a/src/DirectiveProcessing/directive_analyzer.cpp b/src/DirectiveProcessing/directive_analyzer.cpp index afc3da8..00d7dd2 100644 --- a/src/DirectiveProcessing/directive_analyzer.cpp +++ b/src/DirectiveProcessing/directive_analyzer.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DirectiveProcessing/directive_creator.cpp b/src/DirectiveProcessing/directive_creator.cpp index 2bd6d86..56225e3 100644 --- a/src/DirectiveProcessing/directive_creator.cpp +++ b/src/DirectiveProcessing/directive_creator.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -22,8 +22,8 @@ #include "../Utils/SgUtils.h" #include "../Sapfor.h" #include "../GraphLoop/graph_loops_func.h" -#include "../Transformations/loop_transform.h" -#include "../ExpressionTransform/expr_transform.h" +#include "../Transformations/LoopNesting/loop_transform.h" +#include "expr_transform.h" #include "../GraphCall/graph_calls_func.h" #include "../Utils/AstWrapper.h" diff --git a/src/DirectiveProcessing/directive_creator_base.cpp b/src/DirectiveProcessing/directive_creator_base.cpp index 6a7f183..7cb2d4f 100644 --- a/src/DirectiveProcessing/directive_creator_base.cpp +++ b/src/DirectiveProcessing/directive_creator_base.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -10,7 +10,7 @@ #include "../ParallelizationRegions/ParRegions.h" #include "../Distribution/Arrays.h" -#include "../Transformations/loop_transform.h" +#include "../Transformations/LoopNesting/loop_transform.h" #include "../Utils/errors.h" #include "directive_parser.h" diff --git a/src/DirectiveProcessing/directive_omp_parser.cpp b/src/DirectiveProcessing/directive_omp_parser.cpp index 6654abf..3fd3a92 100644 --- a/src/DirectiveProcessing/directive_omp_parser.cpp +++ b/src/DirectiveProcessing/directive_omp_parser.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DirectiveProcessing/directive_parser.cpp b/src/DirectiveProcessing/directive_parser.cpp index ac11540..3e4b901 100644 --- a/src/DirectiveProcessing/directive_parser.cpp +++ b/src/DirectiveProcessing/directive_parser.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DirectiveProcessing/insert_directive.cpp b/src/DirectiveProcessing/insert_directive.cpp index 4a8f7ed..e2d1ed2 100644 --- a/src/DirectiveProcessing/insert_directive.cpp +++ b/src/DirectiveProcessing/insert_directive.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DirectiveProcessing/remote_access.cpp b/src/DirectiveProcessing/remote_access.cpp index a35c844..1df252b 100644 --- a/src/DirectiveProcessing/remote_access.cpp +++ b/src/DirectiveProcessing/remote_access.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -22,7 +22,7 @@ #include "../Utils/errors.h" #include "../Utils/SgUtils.h" #include "../Distribution/Arrays.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" #include "../GraphLoop/graph_loops_func.h" #include "remote_access.h" diff --git a/src/DirectiveProcessing/remote_access_base.cpp b/src/DirectiveProcessing/remote_access_base.cpp index c81ddbf..fe027e1 100644 --- a/src/DirectiveProcessing/remote_access_base.cpp +++ b/src/DirectiveProcessing/remote_access_base.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -17,7 +17,7 @@ #include #include "../Distribution/Arrays.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphLoop/graph_loops.h" #include "../ParallelizationRegions/ParRegions.h" #include "remote_access.h" diff --git a/src/DirectiveProcessing/shadow.cpp b/src/DirectiveProcessing/shadow.cpp index e8eb705..b0a3b92 100644 --- a/src/DirectiveProcessing/shadow.cpp +++ b/src/DirectiveProcessing/shadow.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -8,12 +8,12 @@ #include "../Utils/errors.h" #include "../Utils/utils.h" #include "../GraphLoop/graph_loops_func.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" #include "directive_parser.h" #include "../Distribution/DvmhDirective_func.h" #include "../Utils/SgUtils.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../CFGraph/CFGraph.h" diff --git a/src/DirectiveProcessing/spf_directive_preproc.cpp b/src/DirectiveProcessing/spf_directive_preproc.cpp index da7ddee..e380df5 100644 --- a/src/DirectiveProcessing/spf_directive_preproc.cpp +++ b/src/DirectiveProcessing/spf_directive_preproc.cpp @@ -1,4 +1,4 @@ -п»ї#include "../Utils/leak_detector.h" +п»ї#include "leak_detector.h" #include #include @@ -18,7 +18,7 @@ #include "../Utils/SgUtils.h" #include "../Utils/errors.h" #include "directive_parser.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../DirectiveProcessing/directive_omp_parser.h" diff --git a/src/Distribution/Array.cpp b/src/Distribution/Array.cpp index 4149bda..c3cc653 100644 --- a/src/Distribution/Array.cpp +++ b/src/Distribution/Array.cpp @@ -1,7 +1,7 @@ #include "Array.h" #include "../Utils/errors.h" #include "../Utils/utils.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" using namespace std; diff --git a/src/Distribution/ArrayAnalysis.cpp b/src/Distribution/ArrayAnalysis.cpp index c56f3a4..56527b7 100644 --- a/src/Distribution/ArrayAnalysis.cpp +++ b/src/Distribution/ArrayAnalysis.cpp @@ -1,7 +1,7 @@ #include "Array.h" #include "../Utils/errors.h" #include "../Utils/utils.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../Utils/SgUtils.h" #include "../DirectiveProcessing/directive_parser.h" #include "../DirectiveProcessing/directive_omp_parser.h" diff --git a/src/Distribution/CreateDistributionDirs.cpp b/src/Distribution/CreateDistributionDirs.cpp index ef34757..cdb2720 100644 --- a/src/Distribution/CreateDistributionDirs.cpp +++ b/src/Distribution/CreateDistributionDirs.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Distribution/Cycle.cpp b/src/Distribution/Cycle.cpp index bb307ba..ade7a12 100644 --- a/src/Distribution/Cycle.cpp +++ b/src/Distribution/Cycle.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Distribution/Distribution.cpp b/src/Distribution/Distribution.cpp index 6f99a0c..1ec89fb 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Distribution/DvmhDirective.cpp b/src/Distribution/DvmhDirective.cpp index 1f8f0d2..b485a6e 100644 --- a/src/Distribution/DvmhDirective.cpp +++ b/src/Distribution/DvmhDirective.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Distribution/DvmhDirectiveBase.cpp b/src/Distribution/DvmhDirectiveBase.cpp index 28576a8..0cd3f4c 100644 --- a/src/Distribution/DvmhDirectiveBase.cpp +++ b/src/Distribution/DvmhDirectiveBase.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Distribution/GraphCSR.cpp b/src/Distribution/GraphCSR.cpp index 08f712e..0a22ff9 100644 --- a/src/Distribution/GraphCSR.cpp +++ b/src/Distribution/GraphCSR.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DvmhRegions/DvmhRegionInserter.cpp b/src/DvmhRegions/DvmhRegionInserter.cpp index 57dff85..db6f51d 100644 --- a/src/DvmhRegions/DvmhRegionInserter.cpp +++ b/src/DvmhRegions/DvmhRegionInserter.cpp @@ -11,7 +11,7 @@ #include "DvmhRegionInserter.h" #include "DvmhRegions/RegionsMerger.h" #include "../VerificationCode/verifications.h" -#include "../Transformations/function_purifying.h" +#include "../Transformations/FunctionPurifying/function_purifying.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../DirectiveProcessing/directive_parser.h" diff --git a/src/DvmhRegions/DvmhRegionInserter.h b/src/DvmhRegions/DvmhRegionInserter.h index eba428d..8d34be1 100644 --- a/src/DvmhRegions/DvmhRegionInserter.h +++ b/src/DvmhRegions/DvmhRegionInserter.h @@ -2,7 +2,7 @@ #include "../GraphCall/graph_calls_func.h" #include "../GraphLoop/graph_loops_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../ParallelizationRegions/ParRegions.h" #include "../Utils/SgUtils.h" #include "ReadWriteAnalyzer.h" diff --git a/src/DynamicAnalysis/createParallelRegions.cpp b/src/DynamicAnalysis/createParallelRegions.cpp index 43be93b..7d641c3 100644 --- a/src/DynamicAnalysis/createParallelRegions.cpp +++ b/src/DynamicAnalysis/createParallelRegions.cpp @@ -5,10 +5,10 @@ #include "./createParallelRegions.h" #include "../CreateInterTree/CreateInterTree.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "./gcov_info.h" #include "./gCov_parser_func.h" -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DynamicAnalysis/createParallelRegions.h b/src/DynamicAnalysis/createParallelRegions.h index 8818511..a75c928 100644 --- a/src/DynamicAnalysis/createParallelRegions.h +++ b/src/DynamicAnalysis/createParallelRegions.h @@ -4,7 +4,7 @@ #include "./gcov_info.h" #include "../CreateInterTree/CreateInterTree.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include #include diff --git a/src/DynamicAnalysis/gCov_parser.cpp b/src/DynamicAnalysis/gCov_parser.cpp index c8db6e7..dd2cb90 100644 --- a/src/DynamicAnalysis/gCov_parser.cpp +++ b/src/DynamicAnalysis/gCov_parser.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/DynamicAnalysis/gcov_info.cpp b/src/DynamicAnalysis/gcov_info.cpp index c37cf81..c34d64a 100644 --- a/src/DynamicAnalysis/gcov_info.cpp +++ b/src/DynamicAnalysis/gcov_info.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/GraphCall/graph_calls.cpp b/src/GraphCall/graph_calls.cpp index 4ce117d..530f9b1 100644 --- a/src/GraphCall/graph_calls.cpp +++ b/src/GraphCall/graph_calls.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -21,7 +21,7 @@ #include "../Utils/json.hpp" #include "../ParallelizationRegions/ParRegions_func.h" #include "../DynamicAnalysis/gCov_parser_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../VerificationCode/verifications.h" diff --git a/src/GraphCall/graph_calls_base.cpp b/src/GraphCall/graph_calls_base.cpp index 94fdd43..44bb7d2 100644 --- a/src/GraphCall/graph_calls_base.cpp +++ b/src/GraphCall/graph_calls_base.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/GraphLoop/graph_loops.cpp b/src/GraphLoop/graph_loops.cpp index 485fe21..ded6d93 100644 --- a/src/GraphLoop/graph_loops.cpp +++ b/src/GraphLoop/graph_loops.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -14,7 +14,7 @@ #include "../Sapfor.h" #include "../GraphCall/graph_calls_func.h" #include "../ParallelizationRegions/ParRegions_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../Distribution/GraphCSR.h" #include "../Distribution/Arrays.h" @@ -31,7 +31,7 @@ #include "../DirectiveProcessing/directive_parser.h" #include "../DynamicAnalysis/gCov_parser_func.h" -#include "../Transformations/array_assign_to_loop.h" +#include "../Transformations/VectorAssignToLoop/array_assign_to_loop.h" using std::vector; using std::map; diff --git a/src/GraphLoop/graph_loops_base.cpp b/src/GraphLoop/graph_loops_base.cpp index 98e13ca..514c4c5 100644 --- a/src/GraphLoop/graph_loops_base.cpp +++ b/src/GraphLoop/graph_loops_base.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/LoopAnalyzer/allocations_prepoc.cpp b/src/LoopAnalyzer/allocations_prepoc.cpp index fdf04dc..9655798 100644 --- a/src/LoopAnalyzer/allocations_prepoc.cpp +++ b/src/LoopAnalyzer/allocations_prepoc.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/LoopAnalyzer/dep_analyzer.cpp b/src/LoopAnalyzer/dep_analyzer.cpp index 67d99ed..ecf4f2a 100644 --- a/src/LoopAnalyzer/dep_analyzer.cpp +++ b/src/LoopAnalyzer/dep_analyzer.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index a544fca..b284246 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -18,7 +18,7 @@ #include #include -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #if _WIN32 && NDEBUG && __BOOST #include @@ -42,13 +42,13 @@ extern int passDone; #include "../ParallelizationRegions/ParRegions_func.h" #include "../DynamicAnalysis/gCov_parser_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../SageAnalysisTool/depInterfaceExt.h" #include "../VisualizerCalls/get_information.h" #include "../VisualizerCalls/SendMessage.h" -#include "../Transformations/enddo_loop_converter.h" +#include "../Transformations/LoopEndDoConverter/enddo_loop_converter.h" #include "../DirectiveProcessing/remote_access.h" #include "../DirectiveProcessing/directive_omp_parser.h" diff --git a/src/LoopAnalyzer/loop_analyzer.h b/src/LoopAnalyzer/loop_analyzer.h index 5fa5f42..ececa21 100644 --- a/src/LoopAnalyzer/loop_analyzer.h +++ b/src/LoopAnalyzer/loop_analyzer.h @@ -6,7 +6,7 @@ #include #include #include "../GraphLoop/graph_loops.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../ParallelizationRegions/ParRegions.h" #include "../SageAnalysisTool/depInterfaceExt.h" #include "../Utils/AstWrapper.h" diff --git a/src/ParallelizationRegions/ParRegions.cpp b/src/ParallelizationRegions/ParRegions.cpp index f01be39..903fa5e 100644 --- a/src/ParallelizationRegions/ParRegions.cpp +++ b/src/ParallelizationRegions/ParRegions.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -15,7 +15,7 @@ #include "../GraphCall/graph_calls_func.h" #include "../GraphLoop/graph_loops.h" #include "../Distribution/Distribution.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" using std::vector; using std::string; diff --git a/src/ParallelizationRegions/ParRegions_func.h b/src/ParallelizationRegions/ParRegions_func.h index e5d62c6..6420a37 100644 --- a/src/ParallelizationRegions/ParRegions_func.h +++ b/src/ParallelizationRegions/ParRegions_func.h @@ -1,7 +1,7 @@ #pragma once #include "ParRegions.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphLoop/graph_loops.h" void fillRegionLines(SgFile *file, std::vector ®ions, std::vector& messagesForFile, std::vector *loops = NULL, std::vector *funcs = NULL); diff --git a/src/ParallelizationRegions/expand_extract_reg.cpp b/src/ParallelizationRegions/expand_extract_reg.cpp index 5aa341a..86cad84 100644 --- a/src/ParallelizationRegions/expand_extract_reg.cpp +++ b/src/ParallelizationRegions/expand_extract_reg.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp b/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp index 277b46c..43d842f 100644 --- a/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp +++ b/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -17,8 +17,8 @@ #include "../DirectiveProcessing/directive_creator.h" #include "../DirectiveProcessing/insert_directive.h" #include "../Utils/SgUtils.h" -#include "../ExpressionTransform/expr_transform.h" -#include "../Transformations/function_purifying.h" +#include "expr_transform.h" +#include "../Transformations/FunctionPurifying/function_purifying.h" using std::map; using std::pair; diff --git a/src/ParallelizationRegions/resolve_par_reg_conflicts.h b/src/ParallelizationRegions/resolve_par_reg_conflicts.h index 4e5e3c4..1523306 100644 --- a/src/ParallelizationRegions/resolve_par_reg_conflicts.h +++ b/src/ParallelizationRegions/resolve_par_reg_conflicts.h @@ -3,7 +3,7 @@ #include "ParRegions.h" #include "../Utils/SgUtils.h" #include "../Utils/errors.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" void fillRegionIntervals(std::vector ®ions); void fillRegionArrays(std::vector ®ions, const std::map> &allFuncInfo, const std::map &commonBlocks); diff --git a/src/Predictor/PredictScheme.cpp b/src/Predictor/PredictScheme.cpp index a63b241..146427d 100644 --- a/src/Predictor/PredictScheme.cpp +++ b/src/Predictor/PredictScheme.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -20,7 +20,7 @@ #include "../DirectiveProcessing/directive_parser.h" #include "../Distribution/DvmhDirective.h" #include "../GraphLoop/graph_loops_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../CFGraph/CFGraph.h" diff --git a/src/Predictor/PredictScheme.h b/src/Predictor/PredictScheme.h index 35ccf9e..b8fb310 100644 --- a/src/Predictor/PredictScheme.h +++ b/src/Predictor/PredictScheme.h @@ -1,7 +1,7 @@ #pragma once #include #include "dvm.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../Utils/json.hpp" class ParallelStats diff --git a/src/PrivateAnalyzer/private_analyzer.cpp b/src/PrivateAnalyzer/private_analyzer.cpp index deb0c94..99b621e 100644 --- a/src/PrivateAnalyzer/private_analyzer.cpp +++ b/src/PrivateAnalyzer/private_analyzer.cpp @@ -1,5 +1,5 @@ #define _LEAK_ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -9,7 +9,7 @@ #include #include -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "private_analyzer.h" #include "dvm.h" #include "../CFGraph/CFGraph.h" diff --git a/src/PrivateAnalyzer/private_analyzer.h b/src/PrivateAnalyzer/private_analyzer.h index 8835950..1a4804c 100644 --- a/src/PrivateAnalyzer/private_analyzer.h +++ b/src/PrivateAnalyzer/private_analyzer.h @@ -3,7 +3,7 @@ #include #include "dvm.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" extern void Private_Vars_Analyzer(SgStatement* start); void PrivateAnalyzer(SgFile *file, std::vector &funcs); diff --git a/src/ProjectManipulation/ConvertFiles.cpp b/src/ProjectManipulation/ConvertFiles.cpp index 78610d8..1fd7715 100644 --- a/src/ProjectManipulation/ConvertFiles.cpp +++ b/src/ProjectManipulation/ConvertFiles.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/ProjectManipulation/FileInfo.cpp b/src/ProjectManipulation/FileInfo.cpp index aa95940..7aa5215 100644 --- a/src/ProjectManipulation/FileInfo.cpp +++ b/src/ProjectManipulation/FileInfo.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index d474b85..0d1e485 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/ProjectManipulation/PerfAnalyzer.cpp b/src/ProjectManipulation/PerfAnalyzer.cpp index c3ee28c..f8579d1 100644 --- a/src/ProjectManipulation/PerfAnalyzer.cpp +++ b/src/ProjectManipulation/PerfAnalyzer.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index fd395dc..64531b1 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -14,7 +14,7 @@ #include "dvm.h" #include "../Utils/errors.h" #include "../Utils/SgUtils.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" #include "projectParameters.h" diff --git a/src/SageAnalysisTool/defUse.cpp b/src/SageAnalysisTool/defUse.cpp index e400158..24ade01 100644 --- a/src/SageAnalysisTool/defUse.cpp +++ b/src/SageAnalysisTool/defUse.cpp @@ -4,7 +4,7 @@ #include #include -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../Utils/errors.h" #include "../Utils/utils.h" #include "sage++user.h" diff --git a/src/SageAnalysisTool/depGraph.cpp b/src/SageAnalysisTool/depGraph.cpp index a413d99..78a1e6d 100644 --- a/src/SageAnalysisTool/depGraph.cpp +++ b/src/SageAnalysisTool/depGraph.cpp @@ -15,7 +15,7 @@ extern "C" void removeFromCollection(void *pointer); #endif extern int passDone; -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../Utils/errors.h" #include "../VisualizerCalls/get_information.h" diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 9f5ac64..9fd4793 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -24,8 +24,6 @@ #include "ParallelizationRegions/resolve_par_reg_conflicts.h" #include "ParallelizationRegions/expand_extract_reg.h" -#include "Transformations/replace_dist_arrays_in_io.h" - #include "Distribution/Distribution.h" #include "Distribution/GraphCSR.h" #include "Distribution/Arrays.h" @@ -56,7 +54,7 @@ #include "Distribution/CreateDistributionDirs.h" #include "PrivateAnalyzer/private_analyzer.h" #include "PrivateAnalyzer/private_arrays_search.h" -#include "ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "Predictor/PredictScheme.h" #include "Predictor/PredictorModel.h" @@ -72,24 +70,26 @@ #include "VisualizerCalls/SendMessage.h" #include "VisualizerCalls/BuildGraph.h" -#include "Transformations/enddo_loop_converter.h" -#include "Transformations/loop_transform.h" -#include "Transformations/array_assign_to_loop.h" -#include "Transformations/private_arrays_resizing.h" -#include "Transformations/loops_splitter.h" -#include "Transformations/loops_combiner.h" -#include "Transformations/loops_unrolling.h" -#include "Transformations/uniq_call_chain_dup.h" -#include "Transformations/checkpoints.h" -#include "Transformations/swap_array_dims.h" -#include "Transformations/function_purifying.h" -#include "Transformations/private_removing.h" -#include "Transformations/fix_common_blocks.h" -#include "Transformations/convert_to_c.h" -#include "Transformations/set_implicit_none.h" -#include "Transformations/dead_code.h" +#include "Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h" +#include "Transformations/LoopEndDoConverter/enddo_loop_converter.h" +#include "Transformations/LoopNesting/loop_transform.h" +#include "Transformations/VectorAssignToLoop/array_assign_to_loop.h" +#include "Transformations/PrivateArrayResizing/private_arrays_resizing.h" +#include "Transformations/LoopSplitting/loops_splitter.h" +#include "Transformations/LoopCombining/loops_combiner.h" +#include "Transformations/LoopUnrolling/loops_unrolling.h" +#include "Transformations/FunctionDuplication/uniq_call_chain_dup.h" +#include "Transformations/CheckPoints/checkpoints.h" +#include "Transformations/ArrayDimsSwapping/swap_array_dims.h" +#include "Transformations/FunctionPurifying/function_purifying.h" +#include "Transformations/PrivateArrayRemoving/private_removing.h" +#include "Transformations/GlobalVariables/fix_common_blocks.h" +#include "Transformations/ConvertToC/convert_to_c.h" +#include "Transformations/SetImplicitNone/set_implicit_none.h" +#include "Transformations/DeadCodeRemoving/dead_code.h" +#include "Transformations/RenameSymbols/rename_symbols.h" +#include "Transformations/FunctionInlining/inliner.h" -#include "RenameSymbols/rename_symbols.h" #include "ProjectParameters/projectParameters.h" #include "CFGraph/IR.h" @@ -99,8 +99,6 @@ #include "CFGraph/live_variable_analysis.h" #include "CFGraph/private_variables_analysis.h" -#include "Inliner/inliner.h" - #include "dvm.h" #include "Sapfor.h" #include "Utils/PassManager.h" diff --git a/src/Transformations/swap_array_dims.cpp b/src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp similarity index 100% rename from src/Transformations/swap_array_dims.cpp rename to src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp diff --git a/src/Transformations/swap_array_dims.h b/src/Transformations/ArrayDimsSwapping/swap_array_dims.h similarity index 100% rename from src/Transformations/swap_array_dims.h rename to src/Transformations/ArrayDimsSwapping/swap_array_dims.h diff --git a/src/Transformations/checkpoints.cpp b/src/Transformations/CheckPoints/checkpoints.cpp similarity index 97% rename from src/Transformations/checkpoints.cpp rename to src/Transformations/CheckPoints/checkpoints.cpp index 5003f1a..2549f6c 100644 --- a/src/Transformations/checkpoints.cpp +++ b/src/Transformations/CheckPoints/checkpoints.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -6,7 +6,7 @@ #include "../Utils/SgUtils.h" #include "../Utils/utils.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "checkpoints.h" diff --git a/src/Transformations/checkpoints.h b/src/Transformations/CheckPoints/checkpoints.h similarity index 100% rename from src/Transformations/checkpoints.h rename to src/Transformations/CheckPoints/checkpoints.h diff --git a/src/Transformations/convert_to_c.cpp b/src/Transformations/ConvertToC/convert_to_c.cpp similarity index 96% rename from src/Transformations/convert_to_c.cpp rename to src/Transformations/ConvertToC/convert_to_c.cpp index 2b3f7a6..867dc2b 100644 --- a/src/Transformations/convert_to_c.cpp +++ b/src/Transformations/ConvertToC/convert_to_c.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Transformations/convert_to_c.h b/src/Transformations/ConvertToC/convert_to_c.h similarity index 100% rename from src/Transformations/convert_to_c.h rename to src/Transformations/ConvertToC/convert_to_c.h diff --git a/src/Transformations/dead_code.cpp b/src/Transformations/DeadCodeRemoving/dead_code.cpp similarity index 100% rename from src/Transformations/dead_code.cpp rename to src/Transformations/DeadCodeRemoving/dead_code.cpp diff --git a/src/Transformations/dead_code.h b/src/Transformations/DeadCodeRemoving/dead_code.h similarity index 100% rename from src/Transformations/dead_code.h rename to src/Transformations/DeadCodeRemoving/dead_code.h diff --git a/src/ExpressionTransform/control_flow_graph_part.cpp b/src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp similarity index 96% rename from src/ExpressionTransform/control_flow_graph_part.cpp rename to src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp index 2245ccb..6f3fa08 100644 --- a/src/ExpressionTransform/control_flow_graph_part.cpp +++ b/src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include "dvm.h" #include "acc_analyzer.h" diff --git a/src/ExpressionTransform/expr_transform.cpp b/src/Transformations/ExpressionSubstitution/expr_transform.cpp similarity index 96% rename from src/ExpressionTransform/expr_transform.cpp rename to src/Transformations/ExpressionSubstitution/expr_transform.cpp index 1fdcf65..e8db58d 100644 --- a/src/ExpressionTransform/expr_transform.cpp +++ b/src/Transformations/ExpressionSubstitution/expr_transform.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #if _WIN32 && NDEBUG && __SPF && __BOOST #include @@ -20,7 +20,7 @@ extern int passDone; #include "../ParallelizationRegions/ParRegions.h" #include "../ParallelizationRegions/ParRegions_func.h" #include "../GraphLoop/graph_loops.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" #include "../Utils/utils.h" #include "../Utils/SgUtils.h" diff --git a/src/ExpressionTransform/expr_transform.h b/src/Transformations/ExpressionSubstitution/expr_transform.h similarity index 96% rename from src/ExpressionTransform/expr_transform.h rename to src/Transformations/ExpressionSubstitution/expr_transform.h index fd11907..c9924d5 100644 --- a/src/ExpressionTransform/expr_transform.h +++ b/src/Transformations/ExpressionSubstitution/expr_transform.h @@ -7,7 +7,7 @@ #include "../Distribution/Distribution.h" #include "../GraphLoop/graph_loops.h" #include "../ParallelizationRegions/ParRegions.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../Utils/SgUtils.h" #include "acc_analyzer.h" diff --git a/src/Transformations/uniq_call_chain_dup.cpp b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp similarity index 96% rename from src/Transformations/uniq_call_chain_dup.cpp rename to src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp index 838df37..8bf71db 100644 --- a/src/Transformations/uniq_call_chain_dup.cpp +++ b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -16,9 +16,9 @@ #include "../Utils/SgUtils.h" #include "uniq_call_chain_dup.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../VerificationCode/verifications.h" using namespace std; diff --git a/src/Transformations/uniq_call_chain_dup.h b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.h similarity index 89% rename from src/Transformations/uniq_call_chain_dup.h rename to src/Transformations/FunctionDuplication/uniq_call_chain_dup.h index 609e978..4e3e16d 100644 --- a/src/Transformations/uniq_call_chain_dup.h +++ b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.h @@ -1,6 +1,6 @@ #pragma once -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include #include #include diff --git a/src/Inliner/inliner.cpp b/src/Transformations/FunctionInlining/inliner.cpp similarity index 97% rename from src/Inliner/inliner.cpp rename to src/Transformations/FunctionInlining/inliner.cpp index ad87c5a..5a00fae 100644 --- a/src/Inliner/inliner.cpp +++ b/src/Transformations/FunctionInlining/inliner.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -14,7 +14,7 @@ #include "../GraphCall/graph_calls_func.h" #include "inliner.h" #include "../VisualizerCalls/SendMessage.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" using std::set; using std::map; diff --git a/src/Inliner/inliner.h b/src/Transformations/FunctionInlining/inliner.h similarity index 100% rename from src/Inliner/inliner.h rename to src/Transformations/FunctionInlining/inliner.h diff --git a/src/Transformations/function_purifying.cpp b/src/Transformations/FunctionPurifying/function_purifying.cpp similarity index 97% rename from src/Transformations/function_purifying.cpp rename to src/Transformations/FunctionPurifying/function_purifying.cpp index 28d454f..af93f22 100644 --- a/src/Transformations/function_purifying.cpp +++ b/src/Transformations/FunctionPurifying/function_purifying.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -15,7 +15,7 @@ #include "../Utils/SgUtils.h" #include "../Utils/CommonBlock.h" #include "../Utils/DefUseList.h" -#include "ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../VerificationCode/verifications.h" #include "../DvmhRegions/DvmhRegionInserter.h" #include "function_purifying.h" diff --git a/src/Transformations/function_purifying.h b/src/Transformations/FunctionPurifying/function_purifying.h similarity index 100% rename from src/Transformations/function_purifying.h rename to src/Transformations/FunctionPurifying/function_purifying.h diff --git a/src/Transformations/fix_common_blocks.cpp b/src/Transformations/GlobalVariables/fix_common_blocks.cpp similarity index 100% rename from src/Transformations/fix_common_blocks.cpp rename to src/Transformations/GlobalVariables/fix_common_blocks.cpp diff --git a/src/Transformations/fix_common_blocks.h b/src/Transformations/GlobalVariables/fix_common_blocks.h similarity index 93% rename from src/Transformations/fix_common_blocks.h rename to src/Transformations/GlobalVariables/fix_common_blocks.h index 60b5855..8c0ff32 100644 --- a/src/Transformations/fix_common_blocks.h +++ b/src/Transformations/GlobalVariables/fix_common_blocks.h @@ -11,7 +11,7 @@ #include "../Utils/SgUtils.h" #include "../LoopAnalyzer/loop_analyzer.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" struct DeclInfo // for error messages diff --git a/src/Transformations/loops_combiner.cpp b/src/Transformations/LoopCombining/loops_combiner.cpp similarity index 96% rename from src/Transformations/loops_combiner.cpp rename to src/Transformations/LoopCombining/loops_combiner.cpp index ae5db2e..81ca24c 100644 --- a/src/Transformations/loops_combiner.cpp +++ b/src/Transformations/LoopCombining/loops_combiner.cpp @@ -1,7 +1,7 @@ #include "loops_combiner.h" #include "../LoopAnalyzer/loop_analyzer.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../Utils/errors.h" #include "../Utils/SgUtils.h" #include diff --git a/src/Transformations/loops_combiner.h b/src/Transformations/LoopCombining/loops_combiner.h similarity index 100% rename from src/Transformations/loops_combiner.h rename to src/Transformations/LoopCombining/loops_combiner.h diff --git a/src/Transformations/enddo_loop_converter.cpp b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp similarity index 96% rename from src/Transformations/enddo_loop_converter.cpp rename to src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp index d4c45e1..511b743 100644 --- a/src/Transformations/enddo_loop_converter.cpp +++ b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Transformations/enddo_loop_converter.h b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.h similarity index 100% rename from src/Transformations/enddo_loop_converter.h rename to src/Transformations/LoopEndDoConverter/enddo_loop_converter.h diff --git a/src/Transformations/loop_transform.cpp b/src/Transformations/LoopNesting/loop_transform.cpp similarity index 96% rename from src/Transformations/loop_transform.cpp rename to src/Transformations/LoopNesting/loop_transform.cpp index b720652..6679deb 100644 --- a/src/Transformations/loop_transform.cpp +++ b/src/Transformations/LoopNesting/loop_transform.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Transformations/loop_transform.h b/src/Transformations/LoopNesting/loop_transform.h similarity index 100% rename from src/Transformations/loop_transform.h rename to src/Transformations/LoopNesting/loop_transform.h diff --git a/src/Transformations/loops_splitter.cpp b/src/Transformations/LoopSplitting/loops_splitter.cpp similarity index 97% rename from src/Transformations/loops_splitter.cpp rename to src/Transformations/LoopSplitting/loops_splitter.cpp index 65f7eca..09065d7 100644 --- a/src/Transformations/loops_splitter.cpp +++ b/src/Transformations/LoopSplitting/loops_splitter.cpp @@ -4,7 +4,7 @@ #include #include "../LoopAnalyzer/loop_analyzer.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../Utils/errors.h" #include "../CFGraph/CFGraph.h" #include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h" diff --git a/src/Transformations/loops_splitter.h b/src/Transformations/LoopSplitting/loops_splitter.h similarity index 100% rename from src/Transformations/loops_splitter.h rename to src/Transformations/LoopSplitting/loops_splitter.h diff --git a/src/Transformations/loops_unrolling.cpp b/src/Transformations/LoopUnrolling/loops_unrolling.cpp similarity index 100% rename from src/Transformations/loops_unrolling.cpp rename to src/Transformations/LoopUnrolling/loops_unrolling.cpp diff --git a/src/Transformations/loops_unrolling.h b/src/Transformations/LoopUnrolling/loops_unrolling.h similarity index 100% rename from src/Transformations/loops_unrolling.h rename to src/Transformations/LoopUnrolling/loops_unrolling.h diff --git a/src/Transformations/private_removing.cpp b/src/Transformations/PrivateArrayRemoving/private_removing.cpp similarity index 97% rename from src/Transformations/private_removing.cpp rename to src/Transformations/PrivateArrayRemoving/private_removing.cpp index 51414e8..5589073 100644 --- a/src/Transformations/private_removing.cpp +++ b/src/Transformations/PrivateArrayRemoving/private_removing.cpp @@ -3,8 +3,8 @@ #include "../Utils/errors.h" #include "../Utils/SgUtils.h" #include "../Utils/utils.h" -#include "../ExpressionTransform/expr_transform.h" -#include "dead_code.h" +#include "expr_transform.h" +#include "../DeadCodeRemoving/dead_code.h" using std::make_pair; using std::map; diff --git a/src/Transformations/private_removing.h b/src/Transformations/PrivateArrayRemoving/private_removing.h similarity index 100% rename from src/Transformations/private_removing.h rename to src/Transformations/PrivateArrayRemoving/private_removing.h diff --git a/src/Transformations/private_arrays_resizing.cpp b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp similarity index 100% rename from src/Transformations/private_arrays_resizing.cpp rename to src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp diff --git a/src/Transformations/private_arrays_resizing.h b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.h similarity index 100% rename from src/Transformations/private_arrays_resizing.h rename to src/Transformations/PrivateArrayResizing/private_arrays_resizing.h diff --git a/src/RenameSymbols/rename_symbols.cpp b/src/Transformations/RenameSymbols/rename_symbols.cpp similarity index 96% rename from src/RenameSymbols/rename_symbols.cpp rename to src/Transformations/RenameSymbols/rename_symbols.cpp index 1e812de..bcb593b 100644 --- a/src/RenameSymbols/rename_symbols.cpp +++ b/src/Transformations/RenameSymbols/rename_symbols.cpp @@ -4,7 +4,7 @@ #include #include "Utils/SgUtils.h" -#include "RenameSymbols/rename_symbols.h" +#include "rename_symbols.h" using std::vector; using std::map; diff --git a/src/RenameSymbols/rename_symbols.h b/src/Transformations/RenameSymbols/rename_symbols.h similarity index 100% rename from src/RenameSymbols/rename_symbols.h rename to src/Transformations/RenameSymbols/rename_symbols.h diff --git a/src/Transformations/replace_dist_arrays_in_io.cpp b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp similarity index 96% rename from src/Transformations/replace_dist_arrays_in_io.cpp rename to src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp index efb63e4..e9c088d 100644 --- a/src/Transformations/replace_dist_arrays_in_io.cpp +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp @@ -1,11 +1,11 @@ #include "replace_dist_arrays_in_io.h" -#include "../ParallelizationRegions/resolve_par_reg_conflicts.h" - #include #include #include -#include + +#include "expr_transform.h" +#include "../ParallelizationRegions/resolve_par_reg_conflicts.h" using std::map; using std::set; diff --git a/src/Transformations/replace_dist_arrays_in_io.h b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h similarity index 91% rename from src/Transformations/replace_dist_arrays_in_io.h rename to src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h index a9998ef..cd5c912 100644 --- a/src/Transformations/replace_dist_arrays_in_io.h +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h @@ -3,7 +3,7 @@ #include "../ParallelizationRegions/ParRegions.h" #include "../Utils/SgUtils.h" #include "../Utils/errors.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" void replaceDistributedArraysInIO(std::vector& regions, const std::map>& allFuncInfo, diff --git a/src/Transformations/set_implicit_none.cpp b/src/Transformations/SetImplicitNone/set_implicit_none.cpp similarity index 96% rename from src/Transformations/set_implicit_none.cpp rename to src/Transformations/SetImplicitNone/set_implicit_none.cpp index 8407685..6559a24 100644 --- a/src/Transformations/set_implicit_none.cpp +++ b/src/Transformations/SetImplicitNone/set_implicit_none.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/Transformations/set_implicit_none.h b/src/Transformations/SetImplicitNone/set_implicit_none.h similarity index 100% rename from src/Transformations/set_implicit_none.h rename to src/Transformations/SetImplicitNone/set_implicit_none.h diff --git a/src/Transformations/array_assign_to_loop.cpp b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp similarity index 97% rename from src/Transformations/array_assign_to_loop.cpp rename to src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp index 01bd012..20e1d37 100644 --- a/src/Transformations/array_assign_to_loop.cpp +++ b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -14,7 +14,7 @@ #include "../ParallelizationRegions/ParRegions.h" #include "array_assign_to_loop.h" #include "../Utils/SgUtils.h" -#include "../ExpressionTransform/expr_transform.h" +#include "expr_transform.h" #include "../GraphCall/graph_calls_func.h" #include "../VerificationCode/verifications.h" diff --git a/src/Transformations/array_assign_to_loop.h b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.h similarity index 100% rename from src/Transformations/array_assign_to_loop.h rename to src/Transformations/VectorAssignToLoop/array_assign_to_loop.h diff --git a/src/Utils/SgUtils.cpp b/src/Utils/SgUtils.cpp index 677e0a9..51b0dce 100644 --- a/src/Utils/SgUtils.cpp +++ b/src/Utils/SgUtils.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include @@ -37,7 +37,7 @@ #include "../DirectiveProcessing/directive_parser.h" #include "../Distribution/Distribution.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../GraphCall/graph_calls_func.h" #include "../CreateInterTree/CreateInterTree.h" #include "../Predictor/PredictScheme.h" diff --git a/src/Utils/SgUtils.h b/src/Utils/SgUtils.h index 5ce6d38..68b726e 100644 --- a/src/Utils/SgUtils.h +++ b/src/Utils/SgUtils.h @@ -3,7 +3,7 @@ #include "dvm.h" #include "utils.h" #include "../Distribution/Distribution.h" -#include "../GraphCall/graph_calls.h" +#include "graph_calls.h" #include "../DynamicAnalysis/gcov_info.h" #include "module_utils.h" diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index 2ee26d1..e9f8bcf 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/VerificationCode/CorrectVarDecl.cpp b/src/VerificationCode/CorrectVarDecl.cpp index 96625f0..ccae540 100644 --- a/src/VerificationCode/CorrectVarDecl.cpp +++ b/src/VerificationCode/CorrectVarDecl.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/VerificationCode/IncludeChecker.cpp b/src/VerificationCode/IncludeChecker.cpp index 15fe93e..04ad02f 100644 --- a/src/VerificationCode/IncludeChecker.cpp +++ b/src/VerificationCode/IncludeChecker.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/VerificationCode/StructureChecker.cpp b/src/VerificationCode/StructureChecker.cpp index 407510b..1eb17b4 100644 --- a/src/VerificationCode/StructureChecker.cpp +++ b/src/VerificationCode/StructureChecker.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include diff --git a/src/VerificationCode/VerifySageStructures.cpp b/src/VerificationCode/VerifySageStructures.cpp index 0c8da72..1056bcc 100644 --- a/src/VerificationCode/VerifySageStructures.cpp +++ b/src/VerificationCode/VerifySageStructures.cpp @@ -1,4 +1,4 @@ -#include "../Utils/leak_detector.h" +#include "leak_detector.h" #include #include From db32a3e2b288237b2955a29aee255ac49884ad67 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Jun 2025 08:32:25 +0300 Subject: [PATCH 12/32] small fix --- src/Sapfor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 9fd4793..36f8cfa 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2678,7 +2678,7 @@ int main(int argc, char **argv) byFileArray.push_back(inFile); } json allMessages; - allMessages["allMessage"] = byFileArray; + allMessages["allMessages"] = byFileArray; FILE* outF = fopen("dump_messages.json", "w"); fprintf(outF, "%s", allMessages.dump().c_str()); From c6a0c7328721caa7ad253dd7a93d21df1ad466e2 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Wed, 4 Jun 2025 09:18:24 +0300 Subject: [PATCH 13/32] fix UB in dom tree builder --- src/CFGraph/CFGraph.h | 8 +------- src/CFGraph/IR_domTree.cpp | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/CFGraph/CFGraph.h b/src/CFGraph/CFGraph.h index f0308fd..8dfeb6a 100644 --- a/src/CFGraph/CFGraph.h +++ b/src/CFGraph/CFGraph.h @@ -73,13 +73,7 @@ namespace SAPFOR const std::vector& getNext() const { return next; } const std::vector& getPrev() const { return prev; } BasicBlock* getDom() const - { - if (!directDominator) - { - __spf_print(1, "%s\n", "the dominator tree was built with an error or was not built at all"); - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - } - + { return directDominator; } diff --git a/src/CFGraph/IR_domTree.cpp b/src/CFGraph/IR_domTree.cpp index cfab670..067cc7c 100644 --- a/src/CFGraph/IR_domTree.cpp +++ b/src/CFGraph/IR_domTree.cpp @@ -64,6 +64,8 @@ namespace SAPFOR { int w = vertex[i]; for (BasicBlock* v : vertices[w]->getPrev()) { + if (dfs_num[v] == -1) + continue; int u = Eval(dfs_num[v]); if (semi[u] < semi[w]) @@ -97,4 +99,4 @@ namespace SAPFOR { void buildDominatorTree(std::vector& blocks) { DominatorFinder finder(blocks); } -} \ No newline at end of file +} From ae9cc2bf3b8e82235f9ffc58ff0e9b515ffa03d3 Mon Sep 17 00:00:00 2001 From: Vladislav Abrosimov Date: Wed, 4 Jun 2025 09:19:10 +0300 Subject: [PATCH 14/32] Fix set iterators invalidation in find_parameters --- src/ProjectParameters/projectParameters.cpp | 8 ++++++-- src/ProjectParameters/projectParameters.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index af7c038..997f57c 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -131,9 +131,9 @@ static void lookup_for_vars(set>& where_to_add if (worklist.count(result_arg)) { + worklist.erase(result_arg); processArgument(worklist, arg1, cur_instr, first_instr); processArgument(worklist, arg2, cur_instr, first_instr); - worklist.erase(result_arg); } if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1)) @@ -159,6 +159,8 @@ static void lookup_for_vars(set>& where_to_add const auto& RD = bblock->getRD_In(); map group_by_block; + + set to_erase; for (auto& arg : worklist) { if (RD.count(arg)) @@ -175,7 +177,7 @@ static void lookup_for_vars(set>& where_to_add __spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename); auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE); where_to_add.insert(toAdd); - worklist.erase(arg); + to_erase.insert(arg); } else { @@ -186,6 +188,8 @@ static void lookup_for_vars(set>& where_to_add } } } + for (const auto& arg : to_erase) + worklist.erase(arg); while (bblock && group_by_block.find(bblock) == group_by_block.end()) bblock = bblock->getDom(); diff --git a/src/ProjectParameters/projectParameters.h b/src/ProjectParameters/projectParameters.h index 83a69e3..5be0d3c 100644 --- a/src/ProjectParameters/projectParameters.h +++ b/src/ProjectParameters/projectParameters.h @@ -5,7 +5,7 @@ #include #include -#include "..\GraphCall\graph_calls.h" +#include "../GraphCall/graph_calls.h" using ResultSet = std::set>; From f53d514a47c113014dfaefdba55346d5dae458d7 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Jun 2025 13:01:50 +0300 Subject: [PATCH 15/32] added VISUALIZER_DATA_PATH variable --- src/ProjectManipulation/ParseFiles.cpp | 9 ++--- src/Sapfor.cpp | 45 +++++++++++++------------ src/SapforData.h | 1 + src/Utils/version.h | 2 +- src/VisualizerCalls/get_information.cpp | 3 +- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index 0d1e485..3e6e40a 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -34,6 +34,7 @@ using namespace std; extern "C" int parse_file(int argc, char* argv[], char* proj_name); +extern const char* VISUALIZER_DATA_PATH; static void findModuleDeclInProject(const string& name, const vector& files, map& modDecls) { @@ -713,7 +714,7 @@ int parseFiles(const char* proj, vector& filesCompilationOrder, int pars if (pathSplit.size() < 2) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - if (pathSplit[pathSplit.size() - 2] != "visualiser_data") + if (pathSplit[pathSplit.size() - 2] != VISUALIZER_DATA_PATH) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); string fullPath = ""; for (int z = 0; z < pathSplit.size() - 2; ++z) @@ -745,9 +746,9 @@ int parseFiles(const char* proj, vector& filesCompilationOrder, int pars else fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd; - const string optPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".opt"; - const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err"; - const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out"; + const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt"; + const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err"; + const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out"; const string fileText = readFileToStr(toAdd); diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 36f8cfa..1106d5f 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -908,7 +908,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == ADD_TEMPL_TO_USE_ONLY) fixUseOnlyStmt(file, parallelRegions); else if (curr_regime == GCOV_PARSER) - parse_gcovfile(file, consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, gCovInfo), keepFiles); + parse_gcovfile(file, consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, gCovInfo), keepFiles); else if(curr_regime == PRIVATE_ARRAYS_EXPANSION) { auto founded = loopGraph.find(file->filename()); @@ -960,7 +960,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne vector include_functions; createInterTree(file, getObjectForFileFromMap(file_name, intervals), removeNestedIntervals, getObjectForFileFromMap(file_name, SPF_messages)); - assignCallsToFile(consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, intervals)); + assignCallsToFile(consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, intervals)); removeNodes(intervals_threshold, getObjectForFileFromMap(file_name, intervals), include_functions); } else if (curr_regime == INSERT_INTER_TREE) @@ -1713,7 +1713,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne } else if (curr_regime == GCOV_PARSER) { - parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : "./visualiser_data/statistic/" + string("statistic.txt"), intervals); + parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : string(VISUALIZER_DATA_PATH) + "/statistic/statistic.txt", intervals); //fixed count, devide by value from PROG_HEDR SgStatement* mainUnit = findMainUnit(&project, SPF_messages); @@ -2662,27 +2662,30 @@ int main(int argc, char **argv) printStackTrace(); printf("exception occurred\n"); - json byFileArray = json::array(); - for (auto& byFile : SPF_messages) + FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "error_messages.json").c_str(), "w"); + if (outF) { - json inFile; - inFile["file"] = byFile.first; - - json messages = json::array(); - for (auto& message : byFile.second) + json byFileArray = json::array(); + for (auto& byFile : SPF_messages) { - message.print(byFile.first); - messages.push_back(message.toJson()); - } - inFile["messages"] = messages; - byFileArray.push_back(inFile); - } - json allMessages; - allMessages["allMessages"] = byFileArray; + json inFile; + inFile["file"] = byFile.first; - FILE* outF = fopen("dump_messages.json", "w"); - fprintf(outF, "%s", allMessages.dump().c_str()); - fclose(outF); + json messages = json::array(); + for (auto& message : byFile.second) + { + message.print(byFile.first); + messages.push_back(message.toJson()); + } + inFile["messages"] = messages; + byFileArray.push_back(inFile); + } + json allMessages; + allMessages["allMessages"] = byFileArray; + + fprintf(outF, "%s", allMessages.dump().c_str()); + fclose(outF); + } } deleteAllAllocatedData(withDel); diff --git a/src/SapforData.h b/src/SapforData.h index cfd4f42..b62ae99 100644 --- a/src/SapforData.h +++ b/src/SapforData.h @@ -49,6 +49,7 @@ bool withTemplateInfo = false; bool inlcudeAllFiles = false; // for pass INSERT_INLCUDES bool runAsClient = false; // run console project as client for Visualizer bool printSymbTable = false; +const char* VISUALIZER_DATA_PATH = "visualiser_data"; uint64_t currentAvailMemory = 0; int QUALITY; // quality of conflicts search in graph diff --git a/src/Utils/version.h b/src/Utils/version.h index 43758a9..6f49767 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2422" +#define VERSION_SPF "2423" diff --git a/src/VisualizerCalls/get_information.cpp b/src/VisualizerCalls/get_information.cpp index 8aa5102..1e2adf1 100644 --- a/src/VisualizerCalls/get_information.cpp +++ b/src/VisualizerCalls/get_information.cpp @@ -67,6 +67,7 @@ using json = nlohmann::json; extern set allocated; extern set allocatedInt; extern bool runAsClient; +extern const char* VISUALIZER_DATA_PATH; bool showDebug = false; static const string interruptEx = "Interrupted by user"; @@ -298,7 +299,7 @@ static void runPassesForVisualizer(const short *projName, const vector & while (passDone == 0) { FILE* interrupt_old = fopen("INTERRUPT", "r"); - FILE* interrupt = fopen("visualiser_data/INTERRUPT", "r"); + FILE* interrupt = fopen((string(VISUALIZER_DATA_PATH) + "/INTERRUPT").c_str(), "r"); if (interrupt || interrupt_old) { if (showDebug) From fca4f632e470975b66da331dd70de905e56f4907 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Jun 2025 13:08:38 +0300 Subject: [PATCH 16/32] refactoring: removed unnecessary --- src/CFGraph/CFGraph.cpp | 4 ++-- src/CFGraph/DataFlow/backward_data_flow.h | 2 +- src/CFGraph/DataFlow/backward_data_flow_impl.h | 2 +- src/CFGraph/DataFlow/data_flow.h | 2 +- src/CFGraph/DataFlow/data_flow_impl.h | 2 +- src/CFGraph/IR.cpp | 4 ++-- src/CFGraph/IR.h | 2 +- src/CFGraph/RD_subst.cpp | 4 ++-- src/CFGraph/RD_subst.h | 4 ++-- src/CFGraph/live_variable_analysis.h | 2 +- src/CFGraph/private_variables_analysis.cpp | 4 ++-- src/CFGraph/private_variables_analysis.h | 4 ++-- src/CreateInterTree/CreateInterTree.cpp | 6 +++--- src/CreateInterTree/CreateInterTree.h | 2 +- src/DirectiveProcessing/directive_analyzer.cpp | 4 ++-- src/DirectiveProcessing/directive_analyzer.h | 2 +- src/DirectiveProcessing/directive_creator.cpp | 10 +++++----- src/DirectiveProcessing/directive_creator.h | 6 +++--- src/DirectiveProcessing/directive_creator_base.cpp | 2 +- src/DirectiveProcessing/directive_omp_parser.cpp | 2 +- src/DirectiveProcessing/directive_omp_parser.h | 2 +- src/DirectiveProcessing/directive_parser.cpp | 6 +++--- src/DirectiveProcessing/directive_parser.h | 4 ++-- src/DirectiveProcessing/insert_directive.cpp | 8 ++++---- src/DirectiveProcessing/remote_access.cpp | 10 +++++----- src/DirectiveProcessing/remote_access_base.cpp | 2 +- src/DirectiveProcessing/shadow.cpp | 10 +++++----- src/DirectiveProcessing/spf_directive_preproc.cpp | 8 ++++---- src/Distribution/Array.cpp | 4 ++-- src/Distribution/Array.h | 6 +++--- src/Distribution/ArrayAnalysis.cpp | 6 +++--- src/Distribution/CreateDistributionDirs.cpp | 6 +++--- src/Distribution/CreateDistributionDirs.h | 4 ++-- src/Distribution/Cycle.h | 2 +- src/Distribution/Distribution.cpp | 6 +++--- src/Distribution/DvmhDirective.cpp | 8 ++++---- src/Distribution/DvmhDirective.h | 6 +++--- src/Distribution/DvmhDirectiveBase.cpp | 8 ++++---- src/Distribution/DvmhDirectiveBase.h | 2 +- src/Distribution/DvmhDirective_func.h | 2 +- src/Distribution/GraphCSR.cpp | 4 ++-- src/Distribution/GraphCSR.h | 2 +- src/DvmhRegions/DvmhRegion.h | 2 +- src/DvmhRegions/DvmhRegionInserter.h | 6 +++--- src/DvmhRegions/LoopChecker.h | 4 ++-- src/DvmhRegions/ReadWriteAnalyzer.h | 2 +- src/DvmhRegions/TypedSymbol.h | 2 +- src/DynamicAnalysis/createParallelRegions.h | 2 +- src/DynamicAnalysis/gCov_parser.cpp | 2 +- src/DynamicAnalysis/gCov_parser_func.h | 2 +- src/DynamicAnalysis/gcov_info.cpp | 2 +- src/DynamicAnalysis/gcov_info.h | 2 +- src/GraphCall/graph_calls.cpp | 6 +++--- src/GraphCall/graph_calls.h | 6 +++--- src/GraphCall/graph_calls_base.cpp | 4 ++-- src/GraphCall/graph_calls_func.h | 2 +- src/GraphLoop/graph_loops.cpp | 12 ++++++------ src/GraphLoop/graph_loops.h | 4 ++-- src/GraphLoop/graph_loops_base.cpp | 4 ++-- src/LoopAnalyzer/allocations_prepoc.cpp | 4 ++-- src/LoopAnalyzer/dep_analyzer.cpp | 4 ++-- src/LoopAnalyzer/loop_analyzer.cpp | 10 +++++----- src/LoopAnalyzer/loop_analyzer.h | 6 +++--- src/ParallelizationRegions/ParRegions.cpp | 8 ++++---- src/ParallelizationRegions/ParRegions.h | 6 +++--- src/ParallelizationRegions/ParRegions_func.h | 2 +- src/ParallelizationRegions/expand_extract_reg.h | 4 ++-- .../resolve_par_reg_conflicts.cpp | 6 +++--- .../resolve_par_reg_conflicts.h | 4 ++-- src/Predictor/PredictScheme.cpp | 4 ++-- src/Predictor/PredictScheme.h | 2 +- src/PrivateAnalyzer/private_arrays_search.cpp | 4 ++-- src/PrivateAnalyzer/private_arrays_search.h | 2 +- src/PrivateAnalyzer/region.cpp | 2 +- src/PrivateAnalyzer/region.h | 2 +- src/ProjectManipulation/ConvertFiles.cpp | 6 +++--- src/ProjectManipulation/FileInfo.cpp | 4 ++-- src/ProjectManipulation/ParseFiles.cpp | 4 ++-- src/ProjectManipulation/PerfAnalyzer.cpp | 4 ++-- src/ProjectParameters/projectParameters.cpp | 6 +++--- src/SageAnalysisTool/defUse.cpp | 4 ++-- src/SageAnalysisTool/depGraph.cpp | 2 +- .../ArrayDimsSwapping/swap_array_dims.cpp | 6 +++--- src/Transformations/CheckPoints/checkpoints.cpp | 4 ++-- src/Transformations/DeadCodeRemoving/dead_code.h | 2 +- .../ExpressionSubstitution/expr_transform.cpp | 8 ++++---- .../ExpressionSubstitution/expr_transform.h | 4 ++-- .../FunctionDuplication/uniq_call_chain_dup.cpp | 6 +++--- src/Transformations/FunctionInlining/inliner.cpp | 8 ++++---- .../FunctionPurifying/function_purifying.cpp | 8 ++++---- .../GlobalVariables/fix_common_blocks.h | 2 +- src/Transformations/LoopCombining/loops_combiner.cpp | 4 ++-- src/Transformations/LoopCombining/loops_combiner.h | 2 +- .../LoopEndDoConverter/enddo_loop_converter.cpp | 6 +++--- .../LoopEndDoConverter/enddo_loop_converter.h | 2 +- src/Transformations/LoopNesting/loop_transform.cpp | 4 ++-- src/Transformations/LoopNesting/loop_transform.h | 2 +- src/Transformations/LoopSplitting/loops_splitter.cpp | 2 +- src/Transformations/LoopSplitting/loops_splitter.h | 4 ++-- .../LoopUnrolling/loops_unrolling.cpp | 4 ++-- src/Transformations/LoopUnrolling/loops_unrolling.h | 2 +- .../PrivateArrayRemoving/private_removing.cpp | 6 +++--- .../PrivateArrayResizing/private_arrays_resizing.cpp | 8 ++++---- .../PrivateArrayResizing/private_arrays_resizing.h | 2 +- .../ReplaceArraysInIO/replace_dist_arrays_in_io.h | 4 ++-- .../VectorAssignToLoop/array_assign_to_loop.cpp | 4 ++-- .../VectorAssignToLoop/array_assign_to_loop.h | 2 +- src/Utils/SgUtils.cpp | 2 +- src/Utils/module_utils.cpp | 2 +- src/Utils/utils.cpp | 2 +- src/VerificationCode/CorrectVarDecl.cpp | 4 ++-- src/VerificationCode/IncludeChecker.cpp | 6 +++--- src/VerificationCode/StructureChecker.cpp | 6 +++--- src/VerificationCode/VerifySageStructures.cpp | 4 ++-- src/VerificationCode/verifications.h | 4 ++-- src/VisualizerCalls/BuildGraph.cpp | 2 +- src/VisualizerCalls/SendMessage.cpp | 2 +- src/VisualizerCalls/get_information.cpp | 10 +++++----- 118 files changed, 250 insertions(+), 250 deletions(-) diff --git a/src/CFGraph/CFGraph.cpp b/src/CFGraph/CFGraph.cpp index 56af300..a529705 100644 --- a/src/CFGraph/CFGraph.cpp +++ b/src/CFGraph/CFGraph.cpp @@ -8,8 +8,8 @@ #include #include -#include "../Utils/SgUtils.h" -#include "../Utils/CommonBlock.h" +#include "SgUtils.h" +#include "CommonBlock.h" #include "graph_calls.h" #include "dvm.h" diff --git a/src/CFGraph/DataFlow/backward_data_flow.h b/src/CFGraph/DataFlow/backward_data_flow.h index 556af90..bdccf02 100644 --- a/src/CFGraph/DataFlow/backward_data_flow.h +++ b/src/CFGraph/DataFlow/backward_data_flow.h @@ -5,7 +5,7 @@ #include #include -#include "../../Utils/SgUtils.h" +#include "SgUtils.h" #include "../CFGraph.h" #include "../IR.h" diff --git a/src/CFGraph/DataFlow/backward_data_flow_impl.h b/src/CFGraph/DataFlow/backward_data_flow_impl.h index 4578e7b..ae52690 100644 --- a/src/CFGraph/DataFlow/backward_data_flow_impl.h +++ b/src/CFGraph/DataFlow/backward_data_flow_impl.h @@ -5,7 +5,7 @@ #include #include -#include "../../Utils/SgUtils.h" +#include "SgUtils.h" #include "../CFGraph.h" #include "../IR.h" #include "../RD_subst.h" diff --git a/src/CFGraph/DataFlow/data_flow.h b/src/CFGraph/DataFlow/data_flow.h index d58755f..d4b6b3b 100644 --- a/src/CFGraph/DataFlow/data_flow.h +++ b/src/CFGraph/DataFlow/data_flow.h @@ -2,7 +2,7 @@ #include #include -#include "../../Utils/SgUtils.h" +#include "SgUtils.h" #include "../CFGraph.h" #include "../IR.h" diff --git a/src/CFGraph/DataFlow/data_flow_impl.h b/src/CFGraph/DataFlow/data_flow_impl.h index c6a88f6..5a414eb 100644 --- a/src/CFGraph/DataFlow/data_flow_impl.h +++ b/src/CFGraph/DataFlow/data_flow_impl.h @@ -4,7 +4,7 @@ #include #include -#include "../../Utils/SgUtils.h" +#include "SgUtils.h" #include "../CFGraph.h" #include "../IR.h" diff --git a/src/CFGraph/IR.cpp b/src/CFGraph/IR.cpp index 9c110f8..cd2d0ae 100644 --- a/src/CFGraph/IR.cpp +++ b/src/CFGraph/IR.cpp @@ -5,8 +5,8 @@ #include #include -#include "../Utils/SgUtils.h" -#include "../Utils/CommonBlock.h" +#include "SgUtils.h" +#include "CommonBlock.h" #include "graph_calls.h" #include "expr_transform.h" diff --git a/src/CFGraph/IR.h b/src/CFGraph/IR.h index a887a39..97998ac 100644 --- a/src/CFGraph/IR.h +++ b/src/CFGraph/IR.h @@ -6,7 +6,7 @@ #include #include "CFGraph.h" -#include "../Utils/CommonBlock.h" +#include "CommonBlock.h" namespace SAPFOR { diff --git a/src/CFGraph/RD_subst.cpp b/src/CFGraph/RD_subst.cpp index 4f48deb..ac6f00a 100644 --- a/src/CFGraph/RD_subst.cpp +++ b/src/CFGraph/RD_subst.cpp @@ -8,8 +8,8 @@ #include #include -#include "../Utils/SgUtils.h" -#include "../Utils/CommonBlock.h" +#include "SgUtils.h" +#include "CommonBlock.h" #include "graph_calls.h" #include "expr_transform.h" diff --git a/src/CFGraph/RD_subst.h b/src/CFGraph/RD_subst.h index d9e4143..e51c51b 100644 --- a/src/CFGraph/RD_subst.h +++ b/src/CFGraph/RD_subst.h @@ -2,8 +2,8 @@ #include -#include "../Utils/SgUtils.h" -#include "../Utils/CommonBlock.h" +#include "SgUtils.h" +#include "CommonBlock.h" #include "graph_calls.h" #include "CFGraph.h" diff --git a/src/CFGraph/live_variable_analysis.h b/src/CFGraph/live_variable_analysis.h index 9b92523..b5c2d17 100644 --- a/src/CFGraph/live_variable_analysis.h +++ b/src/CFGraph/live_variable_analysis.h @@ -1,6 +1,6 @@ #pragma once -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "CFGraph.h" namespace LIVE_VARIABLES diff --git a/src/CFGraph/private_variables_analysis.cpp b/src/CFGraph/private_variables_analysis.cpp index 72f5fc9..1a5b24a 100644 --- a/src/CFGraph/private_variables_analysis.cpp +++ b/src/CFGraph/private_variables_analysis.cpp @@ -1,6 +1,6 @@ -#include "../Utils/errors.h" +#include "errors.h" #include "private_variables_analysis.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../SageAnalysisTool/depGraph.h" #include "../DirectiveProcessing/directive_parser.h" diff --git a/src/CFGraph/private_variables_analysis.h b/src/CFGraph/private_variables_analysis.h index 649b5cf..59bbb7d 100644 --- a/src/CFGraph/private_variables_analysis.h +++ b/src/CFGraph/private_variables_analysis.h @@ -1,5 +1,5 @@ -#include "../Utils/SgUtils.h" -#include "../GraphLoop/graph_loops.h" +#include "SgUtils.h" +#include "graph_loops.h" #include "CFGraph.h" #include diff --git a/src/CreateInterTree/CreateInterTree.cpp b/src/CreateInterTree/CreateInterTree.cpp index 2699766..c48a111 100644 --- a/src/CreateInterTree/CreateInterTree.cpp +++ b/src/CreateInterTree/CreateInterTree.cpp @@ -1,7 +1,7 @@ #include "CreateInterTree.h" -#include "../Utils/SgUtils.h" -#include "../Utils/utils.h" -#include "../GraphCall/graph_calls_func.h" +#include "SgUtils.h" +#include "utils.h" +#include "graph_calls_func.h" using std::string; using std::wstring; diff --git a/src/CreateInterTree/CreateInterTree.h b/src/CreateInterTree/CreateInterTree.h index d6147a3..74f87db 100644 --- a/src/CreateInterTree/CreateInterTree.h +++ b/src/CreateInterTree/CreateInterTree.h @@ -8,7 +8,7 @@ #include "dvm.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_loops_func.h" struct SpfInterval { diff --git a/src/DirectiveProcessing/directive_analyzer.cpp b/src/DirectiveProcessing/directive_analyzer.cpp index 00d7dd2..198b86a 100644 --- a/src/DirectiveProcessing/directive_analyzer.cpp +++ b/src/DirectiveProcessing/directive_analyzer.cpp @@ -16,9 +16,9 @@ #include #include "../Distribution/DvmhDirective.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "directive_analyzer.h" -#include "../Utils/utils.h" +#include "utils.h" using std::vector; using std::map; diff --git a/src/DirectiveProcessing/directive_analyzer.h b/src/DirectiveProcessing/directive_analyzer.h index 28892b2..bec85df 100644 --- a/src/DirectiveProcessing/directive_analyzer.h +++ b/src/DirectiveProcessing/directive_analyzer.h @@ -1,6 +1,6 @@ #pragma once #include -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" void UniteNestedDirectives(std::vector &loopGraph); diff --git a/src/DirectiveProcessing/directive_creator.cpp b/src/DirectiveProcessing/directive_creator.cpp index 56225e3..1601d27 100644 --- a/src/DirectiveProcessing/directive_creator.cpp +++ b/src/DirectiveProcessing/directive_creator.cpp @@ -15,18 +15,18 @@ #include "../Distribution/Distribution.h" #include "../Distribution/DvmhDirective_func.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "directive_parser.h" #include "directive_creator.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../Sapfor.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_loops_func.h" #include "../Transformations/LoopNesting/loop_transform.h" #include "expr_transform.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" -#include "../Utils/AstWrapper.h" +#include "AstWrapper.h" #define PRINT_DIR_RESULT 0 diff --git a/src/DirectiveProcessing/directive_creator.h b/src/DirectiveProcessing/directive_creator.h index c2f24cd..5b20b8b 100644 --- a/src/DirectiveProcessing/directive_creator.h +++ b/src/DirectiveProcessing/directive_creator.h @@ -1,9 +1,9 @@ #pragma once #include "../Distribution/Distribution.h" -#include "../Utils/errors.h" -#include "../GraphLoop/graph_loops.h" -#include "../Utils/types.h" +#include "errors.h" +#include "graph_loops.h" +#include "types.h" void createParallelDirectives(const std::map> &loopInfo, const std::vector& regions, diff --git a/src/DirectiveProcessing/directive_creator_base.cpp b/src/DirectiveProcessing/directive_creator_base.cpp index 7cb2d4f..7cdb252 100644 --- a/src/DirectiveProcessing/directive_creator_base.cpp +++ b/src/DirectiveProcessing/directive_creator_base.cpp @@ -12,7 +12,7 @@ #include "../Distribution/Arrays.h" #include "../Transformations/LoopNesting/loop_transform.h" -#include "../Utils/errors.h" +#include "errors.h" #include "directive_parser.h" #include "directive_creator.h" diff --git a/src/DirectiveProcessing/directive_omp_parser.cpp b/src/DirectiveProcessing/directive_omp_parser.cpp index 3fd3a92..b54fa3f 100644 --- a/src/DirectiveProcessing/directive_omp_parser.cpp +++ b/src/DirectiveProcessing/directive_omp_parser.cpp @@ -9,7 +9,7 @@ #include "directive_omp_parser.h" #include "directive_parser.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" using std::vector; using std::map; diff --git a/src/DirectiveProcessing/directive_omp_parser.h b/src/DirectiveProcessing/directive_omp_parser.h index 8895289..a34adea 100644 --- a/src/DirectiveProcessing/directive_omp_parser.h +++ b/src/DirectiveProcessing/directive_omp_parser.h @@ -4,7 +4,7 @@ #include #include -#include "../Utils/errors.h" +#include "errors.h" #define SPF_USER_DIR 777 #define SPF_USER_DIR_COPY 999 diff --git a/src/DirectiveProcessing/directive_parser.cpp b/src/DirectiveProcessing/directive_parser.cpp index 3e4b901..e653f26 100644 --- a/src/DirectiveProcessing/directive_parser.cpp +++ b/src/DirectiveProcessing/directive_parser.cpp @@ -12,10 +12,10 @@ #include #include "directive_parser.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../LoopAnalyzer/loop_analyzer.h" -#include "../Utils/AstWrapper.h" -#include "../Utils/errors.h" +#include "AstWrapper.h" +#include "errors.h" using std::string; using std::vector; diff --git a/src/DirectiveProcessing/directive_parser.h b/src/DirectiveProcessing/directive_parser.h index 4f6bd3c..f632940 100644 --- a/src/DirectiveProcessing/directive_parser.h +++ b/src/DirectiveProcessing/directive_parser.h @@ -4,8 +4,8 @@ #include #include -#include "../Utils/AstWrapper.h" -#include "../GraphLoop/graph_loops.h" +#include "AstWrapper.h" +#include "graph_loops.h" #include "../Distribution/DvmhDirective.h" struct DvmDirective diff --git a/src/DirectiveProcessing/insert_directive.cpp b/src/DirectiveProcessing/insert_directive.cpp index e2d1ed2..c927150 100644 --- a/src/DirectiveProcessing/insert_directive.cpp +++ b/src/DirectiveProcessing/insert_directive.cpp @@ -16,13 +16,13 @@ #include "../Distribution/Arrays.h" #include "../Distribution/Distribution.h" #include "../Distribution/DvmhDirective_func.h" -#include "../GraphLoop/graph_loops_func.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_loops_func.h" +#include "graph_calls_func.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "directive_parser.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../Sapfor.h" #include "directive_creator.h" #include "insert_directive.h" diff --git a/src/DirectiveProcessing/remote_access.cpp b/src/DirectiveProcessing/remote_access.cpp index 1df252b..0323cf1 100644 --- a/src/DirectiveProcessing/remote_access.cpp +++ b/src/DirectiveProcessing/remote_access.cpp @@ -18,13 +18,13 @@ #include "dvm.h" #include "../LoopAnalyzer/loop_analyzer.h" -#include "../Utils/types.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "types.h" +#include "errors.h" +#include "SgUtils.h" #include "../Distribution/Arrays.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_calls_func.h" +#include "graph_loops_func.h" #include "remote_access.h" using std::vector; diff --git a/src/DirectiveProcessing/remote_access_base.cpp b/src/DirectiveProcessing/remote_access_base.cpp index fe027e1..9f2bb39 100644 --- a/src/DirectiveProcessing/remote_access_base.cpp +++ b/src/DirectiveProcessing/remote_access_base.cpp @@ -18,7 +18,7 @@ #include "../Distribution/Arrays.h" #include "graph_calls.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../ParallelizationRegions/ParRegions.h" #include "remote_access.h" diff --git a/src/DirectiveProcessing/shadow.cpp b/src/DirectiveProcessing/shadow.cpp index b0a3b92..ce190ab 100644 --- a/src/DirectiveProcessing/shadow.cpp +++ b/src/DirectiveProcessing/shadow.cpp @@ -5,14 +5,14 @@ #include #include -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../GraphLoop/graph_loops_func.h" +#include "errors.h" +#include "utils.h" +#include "graph_loops_func.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "directive_parser.h" #include "../Distribution/DvmhDirective_func.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "expr_transform.h" #include "../CFGraph/CFGraph.h" diff --git a/src/DirectiveProcessing/spf_directive_preproc.cpp b/src/DirectiveProcessing/spf_directive_preproc.cpp index e380df5..6039de6 100644 --- a/src/DirectiveProcessing/spf_directive_preproc.cpp +++ b/src/DirectiveProcessing/spf_directive_preproc.cpp @@ -12,11 +12,11 @@ #include "dvm.h" #include "../Sapfor.h" -#include "../GraphLoop/graph_loops.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_loops.h" +#include "graph_calls_func.h" #include "../SageAnalysisTool/depInterfaceExt.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "SgUtils.h" +#include "errors.h" #include "directive_parser.h" #include "expr_transform.h" #include "../LoopAnalyzer/loop_analyzer.h" diff --git a/src/Distribution/Array.cpp b/src/Distribution/Array.cpp index c3cc653..8f0cf0c 100644 --- a/src/Distribution/Array.cpp +++ b/src/Distribution/Array.cpp @@ -1,6 +1,6 @@ #include "Array.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "utils.h" #include "graph_calls.h" using namespace std; diff --git a/src/Distribution/Array.h b/src/Distribution/Array.h index 74a8a08..2092451 100644 --- a/src/Distribution/Array.h +++ b/src/Distribution/Array.h @@ -7,9 +7,9 @@ #include #include #include "DvmhDirectiveBase.h" -#include "../Utils/utils.h" -#include "../Utils/errors.h" -#include "../Utils/json.hpp" +#include "utils.h" +#include "errors.h" +#include "json.hpp" class Symbol; class Expression; diff --git a/src/Distribution/ArrayAnalysis.cpp b/src/Distribution/ArrayAnalysis.cpp index 56527b7..57ac0d9 100644 --- a/src/Distribution/ArrayAnalysis.cpp +++ b/src/Distribution/ArrayAnalysis.cpp @@ -1,8 +1,8 @@ #include "Array.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "utils.h" #include "graph_calls.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../DirectiveProcessing/directive_parser.h" #include "../DirectiveProcessing/directive_omp_parser.h" #include "../LoopAnalyzer/loop_analyzer.h" diff --git a/src/Distribution/CreateDistributionDirs.cpp b/src/Distribution/CreateDistributionDirs.cpp index cdb2720..4ec1342 100644 --- a/src/Distribution/CreateDistributionDirs.cpp +++ b/src/Distribution/CreateDistributionDirs.cpp @@ -14,9 +14,9 @@ #include "GraphCSR.h" #include "Arrays.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../GraphLoop/graph_loops.h" +#include "errors.h" +#include "utils.h" +#include "graph_loops.h" using std::vector; using std::set; diff --git a/src/Distribution/CreateDistributionDirs.h b/src/Distribution/CreateDistributionDirs.h index 55c3bee..44eb45d 100644 --- a/src/Distribution/CreateDistributionDirs.h +++ b/src/Distribution/CreateDistributionDirs.h @@ -1,7 +1,7 @@ #pragma once -#include "../GraphLoop/graph_loops.h" -#include "../Utils/errors.h" +#include "graph_loops.h" +#include "errors.h" void createDistributionDirs(DIST::GraphCSR &reducedG, DIST::Arrays &allArrays, DataDirective &dataDirectives, std::map> &allMessages, diff --git a/src/Distribution/Cycle.h b/src/Distribution/Cycle.h index 622bf88..31c7fb5 100644 --- a/src/Distribution/Cycle.h +++ b/src/Distribution/Cycle.h @@ -3,7 +3,7 @@ #include #include -#include "../Utils/types.h" +#include "types.h" namespace Distribution { diff --git a/src/Distribution/Distribution.cpp b/src/Distribution/Distribution.cpp index 1ec89fb..1ff6149 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -30,9 +30,9 @@ using namespace std::chrono; #include "Arrays.h" #include "Array.h" #include "Distribution.h" -#include "../Utils/utils.h" -#include "../Utils/errors.h" -#include "../Utils/types.h" +#include "utils.h" +#include "errors.h" +#include "types.h" #include "../Distribution/Cycle.h" #include "../VisualizerCalls/get_information.h" #include "../VisualizerCalls/SendMessage.h" diff --git a/src/Distribution/DvmhDirective.cpp b/src/Distribution/DvmhDirective.cpp index b485a6e..558f4c0 100644 --- a/src/Distribution/DvmhDirective.cpp +++ b/src/Distribution/DvmhDirective.cpp @@ -7,12 +7,12 @@ #include #include -#include "../Utils/types.h" +#include "types.h" #include "DvmhDirective.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include "../Sapfor.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "dvm.h" diff --git a/src/Distribution/DvmhDirective.h b/src/Distribution/DvmhDirective.h index 24c5425..0d1b7e0 100644 --- a/src/Distribution/DvmhDirective.h +++ b/src/Distribution/DvmhDirective.h @@ -7,9 +7,9 @@ #include "Array.h" #include "DvmhDirectiveBase.h" -#include "../Utils/AstWrapper.h" -#include "../Utils/types.h" -#include "../Utils/utils.h" +#include "AstWrapper.h" +#include "types.h" +#include "utils.h" extern int sharedMemoryParallelization; diff --git a/src/Distribution/DvmhDirectiveBase.cpp b/src/Distribution/DvmhDirectiveBase.cpp index 0cd3f4c..88f2491 100644 --- a/src/Distribution/DvmhDirectiveBase.cpp +++ b/src/Distribution/DvmhDirectiveBase.cpp @@ -10,11 +10,11 @@ #include "../Distribution/Array.h" #include "../Distribution/Arrays.h" #include "../Distribution/GraphCSR.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../Utils/json.hpp" +#include "errors.h" +#include "utils.h" +#include "json.hpp" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" using std::vector; using std::tuple; diff --git a/src/Distribution/DvmhDirectiveBase.h b/src/Distribution/DvmhDirectiveBase.h index d3c98a7..b1bfe90 100644 --- a/src/Distribution/DvmhDirectiveBase.h +++ b/src/Distribution/DvmhDirectiveBase.h @@ -3,7 +3,7 @@ #include #include -#include "../Utils/json.hpp" +#include "json.hpp" typedef enum lang : int { LANG_C, LANG_F } language; typedef enum dist : int { BLOCK, NONE } distType; diff --git a/src/Distribution/DvmhDirective_func.h b/src/Distribution/DvmhDirective_func.h index 78bf560..7d4fa13 100644 --- a/src/Distribution/DvmhDirective_func.h +++ b/src/Distribution/DvmhDirective_func.h @@ -4,7 +4,7 @@ #include #include #include "dvm.h" -#include "../Utils/types.h" +#include "types.h" SgExpression* createAndSetNext(const int side, const int variant, SgExpression *p); std::vector genSubscripts(const std::vector> &shadowRenew, const std::vector> &shadowRenewShifts); diff --git a/src/Distribution/GraphCSR.cpp b/src/Distribution/GraphCSR.cpp index 0a22ff9..1890479 100644 --- a/src/Distribution/GraphCSR.cpp +++ b/src/Distribution/GraphCSR.cpp @@ -19,8 +19,8 @@ extern int passDone; #include "Cycle.h" #include "Arrays.h" #include "Array.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "utils.h" #include "../VisualizerCalls/get_information.h" #include "../VisualizerCalls/SendMessage.h" diff --git a/src/Distribution/GraphCSR.h b/src/Distribution/GraphCSR.h index c52d665..03024de 100644 --- a/src/Distribution/GraphCSR.h +++ b/src/Distribution/GraphCSR.h @@ -5,7 +5,7 @@ #include #include -#include "../Utils/RationalNum.h" +#include "RationalNum.h" typedef enum links { RR_link, WR_link, WW_link } LinkType; diff --git a/src/DvmhRegions/DvmhRegion.h b/src/DvmhRegions/DvmhRegion.h index 10a9d34..2db6d20 100644 --- a/src/DvmhRegions/DvmhRegion.h +++ b/src/DvmhRegions/DvmhRegion.h @@ -1,6 +1,6 @@ #pragma once -#include "../GraphLoop/graph_loops_func.h" +#include "graph_loops_func.h" #include diff --git a/src/DvmhRegions/DvmhRegionInserter.h b/src/DvmhRegions/DvmhRegionInserter.h index 8d34be1..651428d 100644 --- a/src/DvmhRegions/DvmhRegionInserter.h +++ b/src/DvmhRegions/DvmhRegionInserter.h @@ -1,10 +1,10 @@ #pragma once -#include "../GraphCall/graph_calls_func.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_calls_func.h" +#include "graph_loops_func.h" #include "expr_transform.h" #include "../ParallelizationRegions/ParRegions.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "ReadWriteAnalyzer.h" #include "DvmhRegion.h" diff --git a/src/DvmhRegions/LoopChecker.h b/src/DvmhRegions/LoopChecker.h index 793b5ed..6e2c7ae 100644 --- a/src/DvmhRegions/LoopChecker.h +++ b/src/DvmhRegions/LoopChecker.h @@ -1,7 +1,7 @@ #pragma once -#include "../GraphLoop/graph_loops_func.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_loops_func.h" +#include "graph_calls_func.h" #include #include diff --git a/src/DvmhRegions/ReadWriteAnalyzer.h b/src/DvmhRegions/ReadWriteAnalyzer.h index 8e31306..5a9d49f 100644 --- a/src/DvmhRegions/ReadWriteAnalyzer.h +++ b/src/DvmhRegions/ReadWriteAnalyzer.h @@ -1,7 +1,7 @@ #pragma once #include "dvm.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "VarUsages.h" #include #include diff --git a/src/DvmhRegions/TypedSymbol.h b/src/DvmhRegions/TypedSymbol.h index 5e74310..e4b0a03 100644 --- a/src/DvmhRegions/TypedSymbol.h +++ b/src/DvmhRegions/TypedSymbol.h @@ -1,7 +1,7 @@ #pragma once #include "dvm.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include enum class VAR_TYPE { VAR_ARR, VAR_DISTR_ARR, VAR_SCALAR, VAR_ANY, VAR_UNDEFINED }; diff --git a/src/DynamicAnalysis/createParallelRegions.h b/src/DynamicAnalysis/createParallelRegions.h index a75c928..ced7137 100644 --- a/src/DynamicAnalysis/createParallelRegions.h +++ b/src/DynamicAnalysis/createParallelRegions.h @@ -1,6 +1,6 @@ #pragma once -#include "../Utils/utils.h" +#include "utils.h" #include "./gcov_info.h" #include "../CreateInterTree/CreateInterTree.h" diff --git a/src/DynamicAnalysis/gCov_parser.cpp b/src/DynamicAnalysis/gCov_parser.cpp index dd2cb90..53ff70d 100644 --- a/src/DynamicAnalysis/gCov_parser.cpp +++ b/src/DynamicAnalysis/gCov_parser.cpp @@ -8,7 +8,7 @@ #include "dvm.h" #include "gCov_parser_func.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" using namespace std; diff --git a/src/DynamicAnalysis/gCov_parser_func.h b/src/DynamicAnalysis/gCov_parser_func.h index 843d150..87594a9 100644 --- a/src/DynamicAnalysis/gCov_parser_func.h +++ b/src/DynamicAnalysis/gCov_parser_func.h @@ -5,7 +5,7 @@ #include #include "dvm.h" -#include "../Utils/errors.h" +#include "errors.h" #include "gcov_info.h" #include "../CreateInterTree/CreateInterTree.h" diff --git a/src/DynamicAnalysis/gcov_info.cpp b/src/DynamicAnalysis/gcov_info.cpp index c34d64a..0814a68 100644 --- a/src/DynamicAnalysis/gcov_info.cpp +++ b/src/DynamicAnalysis/gcov_info.cpp @@ -4,7 +4,7 @@ #include #include -#include "../Utils/errors.h" +#include "errors.h" #include "gcov_info.h" diff --git a/src/DynamicAnalysis/gcov_info.h b/src/DynamicAnalysis/gcov_info.h index 29f7527..91b09d4 100644 --- a/src/DynamicAnalysis/gcov_info.h +++ b/src/DynamicAnalysis/gcov_info.h @@ -5,7 +5,7 @@ #include #include -#include "../Utils/utils.h" +#include "utils.h" //make 'class' - need friend for Gcov_info struct Perform diff --git a/src/GraphCall/graph_calls.cpp b/src/GraphCall/graph_calls.cpp index 530f9b1..1109d48 100644 --- a/src/GraphCall/graph_calls.cpp +++ b/src/GraphCall/graph_calls.cpp @@ -15,10 +15,10 @@ #include "graph_calls_func.h" #include "../CFGraph/CFGraph.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_loops_func.h" #include "../DirectiveProcessing/directive_parser.h" -#include "../Utils/SgUtils.h" -#include "../Utils/json.hpp" +#include "SgUtils.h" +#include "json.hpp" #include "../ParallelizationRegions/ParRegions_func.h" #include "../DynamicAnalysis/gCov_parser_func.h" #include "expr_transform.h" diff --git a/src/GraphCall/graph_calls.h b/src/GraphCall/graph_calls.h index 17fc462..0de481e 100644 --- a/src/GraphCall/graph_calls.h +++ b/src/GraphCall/graph_calls.h @@ -3,10 +3,10 @@ #include #include -#include "../Utils/AstWrapper.h" -#include "../Utils/utils.h" +#include "AstWrapper.h" +#include "utils.h" #include "../DirectiveProcessing/shadow.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" static const char* paramNames[] = { "NONE_T", "ARRAY_T", "STRING_ARRAY_T", "STRING_T", "SCALAR_CHAR_T", "SCALAR_BOOL_T", "SCALAR_SHORT_T", "SCALAR_INT_T", "SCALAR_LONG_INT_T", diff --git a/src/GraphCall/graph_calls_base.cpp b/src/GraphCall/graph_calls_base.cpp index 44bb7d2..fdb6393 100644 --- a/src/GraphCall/graph_calls_base.cpp +++ b/src/GraphCall/graph_calls_base.cpp @@ -10,10 +10,10 @@ #include #include -#include "../Utils/errors.h" +#include "errors.h" #include "graph_calls.h" #include "../Distribution/Distribution.h" -#include "../Utils/utils.h" +#include "utils.h" #include "../ParallelizationRegions/ParRegions.h" using std::vector; diff --git a/src/GraphCall/graph_calls_func.h b/src/GraphCall/graph_calls_func.h index acba4a7..44e029c 100644 --- a/src/GraphCall/graph_calls_func.h +++ b/src/GraphCall/graph_calls_func.h @@ -5,7 +5,7 @@ #include #include "graph_calls.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../ParallelizationRegions/ParRegions.h" #include "Utils/json.hpp" diff --git a/src/GraphLoop/graph_loops.cpp b/src/GraphLoop/graph_loops.cpp index ded6d93..16438ee 100644 --- a/src/GraphLoop/graph_loops.cpp +++ b/src/GraphLoop/graph_loops.cpp @@ -12,7 +12,7 @@ #include "dvm.h" #include "../Sapfor.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "../ParallelizationRegions/ParRegions_func.h" #include "expr_transform.h" @@ -21,12 +21,12 @@ #include "../Distribution/Distribution.h" #include "graph_loops.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" +#include "utils.h" +#include "SgUtils.h" -#include "../Utils/errors.h" -#include "../Utils/AstWrapper.h" -#include "../Utils/json.hpp" +#include "errors.h" +#include "AstWrapper.h" +#include "json.hpp" #include "../DirectiveProcessing/directive_parser.h" #include "../DynamicAnalysis/gCov_parser_func.h" diff --git a/src/GraphLoop/graph_loops.h b/src/GraphLoop/graph_loops.h index 39fd48b..70d12e5 100644 --- a/src/GraphLoop/graph_loops.h +++ b/src/GraphLoop/graph_loops.h @@ -5,8 +5,8 @@ #include #include -#include "../Utils/errors.h" -#include "../Utils/types.h" +#include "errors.h" +#include "types.h" #include "../Distribution/DvmhDirective.h" #include "../Distribution/Distribution.h" diff --git a/src/GraphLoop/graph_loops_base.cpp b/src/GraphLoop/graph_loops_base.cpp index 514c4c5..031a4d6 100644 --- a/src/GraphLoop/graph_loops_base.cpp +++ b/src/GraphLoop/graph_loops_base.cpp @@ -23,8 +23,8 @@ using std::make_pair; using std::get; #include "graph_loops.h" -#include "../GraphCall/graph_calls_func.h" -#include "../Utils/errors.h" +#include "graph_calls_func.h" +#include "errors.h" #include "../Distribution/Distribution.h" #include "../Distribution/CreateDistributionDirs.h" #include "../ParallelizationRegions/ParRegions.h" diff --git a/src/LoopAnalyzer/allocations_prepoc.cpp b/src/LoopAnalyzer/allocations_prepoc.cpp index 9655798..4d714d2 100644 --- a/src/LoopAnalyzer/allocations_prepoc.cpp +++ b/src/LoopAnalyzer/allocations_prepoc.cpp @@ -8,8 +8,8 @@ #include #include "dvm.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "SgUtils.h" +#include "errors.h" using std::set; using std::pair; diff --git a/src/LoopAnalyzer/dep_analyzer.cpp b/src/LoopAnalyzer/dep_analyzer.cpp index ecf4f2a..aa17a19 100644 --- a/src/LoopAnalyzer/dep_analyzer.cpp +++ b/src/LoopAnalyzer/dep_analyzer.cpp @@ -20,8 +20,8 @@ #include "dvm.h" #include "loop_analyzer.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" +#include "utils.h" +#include "SgUtils.h" #include "../ParallelizationRegions/ParRegions_func.h" #include "../SageAnalysisTool/depGraph.h" #include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h" diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index b284246..cdbbc7d 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -30,15 +30,15 @@ extern int passDone; #include "../Distribution/Arrays.h" #include "../ParallelizationRegions/ParRegions.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../DirectiveProcessing/directive_parser.h" #include "../DirectiveProcessing/directive_creator.h" -#include "../Utils/SgUtils.h" -#include "../Utils/AstWrapper.h" +#include "SgUtils.h" +#include "AstWrapper.h" -#include "../GraphCall/graph_calls_func.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_calls_func.h" +#include "graph_loops_func.h" #include "../ParallelizationRegions/ParRegions_func.h" #include "../DynamicAnalysis/gCov_parser_func.h" diff --git a/src/LoopAnalyzer/loop_analyzer.h b/src/LoopAnalyzer/loop_analyzer.h index ececa21..96e18d2 100644 --- a/src/LoopAnalyzer/loop_analyzer.h +++ b/src/LoopAnalyzer/loop_analyzer.h @@ -5,12 +5,12 @@ #include #include #include -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "graph_calls.h" #include "../ParallelizationRegions/ParRegions.h" #include "../SageAnalysisTool/depInterfaceExt.h" -#include "../Utils/AstWrapper.h" -#include "../Utils/SgUtils.h" +#include "AstWrapper.h" +#include "SgUtils.h" #include "dvm.h" diff --git a/src/ParallelizationRegions/ParRegions.cpp b/src/ParallelizationRegions/ParRegions.cpp index 903fa5e..a05d827 100644 --- a/src/ParallelizationRegions/ParRegions.cpp +++ b/src/ParallelizationRegions/ParRegions.cpp @@ -10,10 +10,10 @@ #include "dvm.h" #include "ParRegions.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" -#include "../GraphCall/graph_calls_func.h" -#include "../GraphLoop/graph_loops.h" +#include "utils.h" +#include "SgUtils.h" +#include "graph_calls_func.h" +#include "graph_loops.h" #include "../Distribution/Distribution.h" #include "expr_transform.h" diff --git a/src/ParallelizationRegions/ParRegions.h b/src/ParallelizationRegions/ParRegions.h index d613d31..6f78563 100644 --- a/src/ParallelizationRegions/ParRegions.h +++ b/src/ParallelizationRegions/ParRegions.h @@ -9,12 +9,12 @@ #include "../Distribution/DvmhDirective.h" #include "../Distribution/GraphCSR.h" #include "../Distribution/Distribution.h" -#include "../Utils/AstWrapper.h" +#include "AstWrapper.h" -#include "../Utils/json.hpp" +#include "json.hpp" #if __SPF -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #endif struct ParallelRegionLines diff --git a/src/ParallelizationRegions/ParRegions_func.h b/src/ParallelizationRegions/ParRegions_func.h index 6420a37..d1ac9b8 100644 --- a/src/ParallelizationRegions/ParRegions_func.h +++ b/src/ParallelizationRegions/ParRegions_func.h @@ -2,7 +2,7 @@ #include "ParRegions.h" #include "graph_calls.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" void fillRegionLines(SgFile *file, std::vector ®ions, std::vector& messagesForFile, std::vector *loops = NULL, std::vector *funcs = NULL); void fillRegionLinesStep2(std::vector ®ions, const std::map> &allFuncInfo, std::map> *loopGraph = NULL); diff --git a/src/ParallelizationRegions/expand_extract_reg.h b/src/ParallelizationRegions/expand_extract_reg.h index c1e0d50..2040a9d 100644 --- a/src/ParallelizationRegions/expand_extract_reg.h +++ b/src/ParallelizationRegions/expand_extract_reg.h @@ -1,7 +1,7 @@ #pragma once #include "ParRegions.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "SgUtils.h" +#include "errors.h" bool expandExtractReg(const std::string &fileName, const int startLine, const int endLine, const std::vector ®ions, std::vector &messagesForFile, const bool toDelete = false); diff --git a/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp b/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp index 43d842f..dc77d6a 100644 --- a/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp +++ b/src/ParallelizationRegions/resolve_par_reg_conflicts.cpp @@ -11,12 +11,12 @@ #include "ParRegions_func.h" #include "resolve_par_reg_conflicts.h" -#include "../GraphCall/graph_calls_func.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_calls_func.h" +#include "graph_loops_func.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../DirectiveProcessing/directive_creator.h" #include "../DirectiveProcessing/insert_directive.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "expr_transform.h" #include "../Transformations/FunctionPurifying/function_purifying.h" diff --git a/src/ParallelizationRegions/resolve_par_reg_conflicts.h b/src/ParallelizationRegions/resolve_par_reg_conflicts.h index 1523306..cfaecbe 100644 --- a/src/ParallelizationRegions/resolve_par_reg_conflicts.h +++ b/src/ParallelizationRegions/resolve_par_reg_conflicts.h @@ -1,8 +1,8 @@ #pragma once #include "ParRegions.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "SgUtils.h" +#include "errors.h" #include "graph_calls.h" void fillRegionIntervals(std::vector ®ions); diff --git a/src/Predictor/PredictScheme.cpp b/src/Predictor/PredictScheme.cpp index 146427d..4e09007 100644 --- a/src/Predictor/PredictScheme.cpp +++ b/src/Predictor/PredictScheme.cpp @@ -16,10 +16,10 @@ #include "../DynamicAnalysis/gcov_info.h" #include "../DynamicAnalysis/gCov_parser_func.h" #include "PredictScheme.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../DirectiveProcessing/directive_parser.h" #include "../Distribution/DvmhDirective.h" -#include "../GraphLoop/graph_loops_func.h" +#include "graph_loops_func.h" #include "expr_transform.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../CFGraph/CFGraph.h" diff --git a/src/Predictor/PredictScheme.h b/src/Predictor/PredictScheme.h index b8fb310..a9c91f2 100644 --- a/src/Predictor/PredictScheme.h +++ b/src/Predictor/PredictScheme.h @@ -2,7 +2,7 @@ #include #include "dvm.h" #include "graph_calls.h" -#include "../Utils/json.hpp" +#include "json.hpp" class ParallelStats { diff --git a/src/PrivateAnalyzer/private_arrays_search.cpp b/src/PrivateAnalyzer/private_arrays_search.cpp index 985baf6..36a6a18 100644 --- a/src/PrivateAnalyzer/private_arrays_search.cpp +++ b/src/PrivateAnalyzer/private_arrays_search.cpp @@ -9,8 +9,8 @@ #include "private_arrays_search.h" #include "range_structures.h" #include "region.h" -#include "../Utils/SgUtils.h" -#include "../GraphLoop/graph_loops.h" +#include "SgUtils.h" +#include "graph_loops.h" #include "../CFGraph/CFGraph.h" using namespace std; diff --git a/src/PrivateAnalyzer/private_arrays_search.h b/src/PrivateAnalyzer/private_arrays_search.h index 2faaa27..504349d 100644 --- a/src/PrivateAnalyzer/private_arrays_search.h +++ b/src/PrivateAnalyzer/private_arrays_search.h @@ -6,7 +6,7 @@ #include "range_structures.h" #include "region.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../CFGraph/CFGraph.h" void Collapse(Region* region); diff --git a/src/PrivateAnalyzer/region.cpp b/src/PrivateAnalyzer/region.cpp index 54540d2..5030fe3 100644 --- a/src/PrivateAnalyzer/region.cpp +++ b/src/PrivateAnalyzer/region.cpp @@ -8,7 +8,7 @@ #include "range_structures.h" #include "region.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" using namespace std; diff --git a/src/PrivateAnalyzer/region.h b/src/PrivateAnalyzer/region.h index 95121b2..4a474ca 100644 --- a/src/PrivateAnalyzer/region.h +++ b/src/PrivateAnalyzer/region.h @@ -5,7 +5,7 @@ #include #include -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../CFGraph/CFGraph.h" class Region : public SAPFOR::BasicBlock { diff --git a/src/ProjectManipulation/ConvertFiles.cpp b/src/ProjectManipulation/ConvertFiles.cpp index 1fd7715..ecfe69a 100644 --- a/src/ProjectManipulation/ConvertFiles.cpp +++ b/src/ProjectManipulation/ConvertFiles.cpp @@ -6,9 +6,9 @@ #include #include -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "SgUtils.h" +#include "utils.h" #include "../VerificationCode/verifications.h" diff --git a/src/ProjectManipulation/FileInfo.cpp b/src/ProjectManipulation/FileInfo.cpp index 7aa5215..d7de1b1 100644 --- a/src/ProjectManipulation/FileInfo.cpp +++ b/src/ProjectManipulation/FileInfo.cpp @@ -7,8 +7,8 @@ #include #include "FileInfo.h" -#include "../Utils/utils.h" -#include "../Utils/errors.h" +#include "utils.h" +#include "errors.h" using namespace std; diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index 3e6e40a..45a68a2 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -22,8 +22,8 @@ #include #include -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include "../VisualizerCalls/get_information.h" #include "../VisualizerCalls/SendMessage.h" diff --git a/src/ProjectManipulation/PerfAnalyzer.cpp b/src/ProjectManipulation/PerfAnalyzer.cpp index f8579d1..bc2428a 100644 --- a/src/ProjectManipulation/PerfAnalyzer.cpp +++ b/src/ProjectManipulation/PerfAnalyzer.cpp @@ -6,8 +6,8 @@ #include #include -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include "StdCapture.h" diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 64531b1..d8d96d9 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -12,10 +12,10 @@ #include #include "dvm.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "projectParameters.h" diff --git a/src/SageAnalysisTool/defUse.cpp b/src/SageAnalysisTool/defUse.cpp index 24ade01..fea079a 100644 --- a/src/SageAnalysisTool/defUse.cpp +++ b/src/SageAnalysisTool/defUse.cpp @@ -5,8 +5,8 @@ #include #include "graph_calls.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "utils.h" #include "sage++user.h" #include "definesValues.h" #include "set.h" diff --git a/src/SageAnalysisTool/depGraph.cpp b/src/SageAnalysisTool/depGraph.cpp index 78a1e6d..800cc45 100644 --- a/src/SageAnalysisTool/depGraph.cpp +++ b/src/SageAnalysisTool/depGraph.cpp @@ -16,7 +16,7 @@ extern "C" void removeFromCollection(void *pointer); extern int passDone; #include "graph_calls.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../VisualizerCalls/get_information.h" #include "sage++user.h" diff --git a/src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp b/src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp index 64685e7..7ebc316 100644 --- a/src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp +++ b/src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp @@ -11,9 +11,9 @@ #include "../Distribution/Array.h" #include "dvm.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "utils.h" +#include "SgUtils.h" using namespace std; diff --git a/src/Transformations/CheckPoints/checkpoints.cpp b/src/Transformations/CheckPoints/checkpoints.cpp index 2549f6c..372d62e 100644 --- a/src/Transformations/CheckPoints/checkpoints.cpp +++ b/src/Transformations/CheckPoints/checkpoints.cpp @@ -4,8 +4,8 @@ #include #include -#include "../Utils/SgUtils.h" -#include "../Utils/utils.h" +#include "SgUtils.h" +#include "utils.h" #include "expr_transform.h" #include "checkpoints.h" diff --git a/src/Transformations/DeadCodeRemoving/dead_code.h b/src/Transformations/DeadCodeRemoving/dead_code.h index 741acff..8f7b1fa 100644 --- a/src/Transformations/DeadCodeRemoving/dead_code.h +++ b/src/Transformations/DeadCodeRemoving/dead_code.h @@ -3,7 +3,7 @@ #include #include -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../CFGraph/CFGraph.h" #include "../CFGraph/live_variable_analysis.h" #include "../CFGraph/DataFlow/data_flow.h" diff --git a/src/Transformations/ExpressionSubstitution/expr_transform.cpp b/src/Transformations/ExpressionSubstitution/expr_transform.cpp index e8db58d..eff3540 100644 --- a/src/Transformations/ExpressionSubstitution/expr_transform.cpp +++ b/src/Transformations/ExpressionSubstitution/expr_transform.cpp @@ -19,11 +19,11 @@ extern int passDone; #include "../ParallelizationRegions/ParRegions.h" #include "../ParallelizationRegions/ParRegions_func.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" +#include "graph_calls_func.h" +#include "utils.h" +#include "SgUtils.h" #include "../Distribution/Distribution.h" #include "../VisualizerCalls/get_information.h" #include "expr_transform.h" diff --git a/src/Transformations/ExpressionSubstitution/expr_transform.h b/src/Transformations/ExpressionSubstitution/expr_transform.h index c9924d5..d79cd06 100644 --- a/src/Transformations/ExpressionSubstitution/expr_transform.h +++ b/src/Transformations/ExpressionSubstitution/expr_transform.h @@ -5,10 +5,10 @@ #include #include "dvm.h" #include "../Distribution/Distribution.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../ParallelizationRegions/ParRegions.h" #include "graph_calls.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "acc_analyzer.h" diff --git a/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp index 8bf71db..b2e5eb9 100644 --- a/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp +++ b/src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp @@ -12,12 +12,12 @@ #include #include "dvm.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include "uniq_call_chain_dup.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "expr_transform.h" #include "../VerificationCode/verifications.h" diff --git a/src/Transformations/FunctionInlining/inliner.cpp b/src/Transformations/FunctionInlining/inliner.cpp index 5a00fae..209cffd 100644 --- a/src/Transformations/FunctionInlining/inliner.cpp +++ b/src/Transformations/FunctionInlining/inliner.cpp @@ -8,10 +8,10 @@ #include #include "dvm.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" -#include "../GraphCall/graph_calls_func.h" +#include "errors.h" +#include "utils.h" +#include "SgUtils.h" +#include "graph_calls_func.h" #include "inliner.h" #include "../VisualizerCalls/SendMessage.h" #include "expr_transform.h" diff --git a/src/Transformations/FunctionPurifying/function_purifying.cpp b/src/Transformations/FunctionPurifying/function_purifying.cpp index af93f22..2eb2470 100644 --- a/src/Transformations/FunctionPurifying/function_purifying.cpp +++ b/src/Transformations/FunctionPurifying/function_purifying.cpp @@ -11,10 +11,10 @@ #include #include "dvm.h" -#include "../GraphCall/graph_calls_func.h" -#include "../Utils/SgUtils.h" -#include "../Utils/CommonBlock.h" -#include "../Utils/DefUseList.h" +#include "graph_calls_func.h" +#include "SgUtils.h" +#include "CommonBlock.h" +#include "DefUseList.h" #include "expr_transform.h" #include "../VerificationCode/verifications.h" #include "../DvmhRegions/DvmhRegionInserter.h" diff --git a/src/Transformations/GlobalVariables/fix_common_blocks.h b/src/Transformations/GlobalVariables/fix_common_blocks.h index 8c0ff32..13bbd3e 100644 --- a/src/Transformations/GlobalVariables/fix_common_blocks.h +++ b/src/Transformations/GlobalVariables/fix_common_blocks.h @@ -8,7 +8,7 @@ #include #include "dvm.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "expr_transform.h" diff --git a/src/Transformations/LoopCombining/loops_combiner.cpp b/src/Transformations/LoopCombining/loops_combiner.cpp index 81ca24c..747839a 100644 --- a/src/Transformations/LoopCombining/loops_combiner.cpp +++ b/src/Transformations/LoopCombining/loops_combiner.cpp @@ -2,8 +2,8 @@ #include "../LoopAnalyzer/loop_analyzer.h" #include "expr_transform.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "SgUtils.h" #include #include #include diff --git a/src/Transformations/LoopCombining/loops_combiner.h b/src/Transformations/LoopCombining/loops_combiner.h index 49244f6..9153a1e 100644 --- a/src/Transformations/LoopCombining/loops_combiner.h +++ b/src/Transformations/LoopCombining/loops_combiner.h @@ -1,7 +1,7 @@ #pragma once #include "dvm.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../SageAnalysisTool/depGraph.h" #include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h" #include "../DirectiveProcessing/directive_parser.h" diff --git a/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp index 511b743..4f1c253 100644 --- a/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp +++ b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp @@ -11,9 +11,9 @@ #include "dvm.h" #include "enddo_loop_converter.h" -#include "../Utils/errors.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" +#include "errors.h" +#include "utils.h" +#include "SgUtils.h" using namespace std; diff --git a/src/Transformations/LoopEndDoConverter/enddo_loop_converter.h b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.h index 6de9691..39a307b 100644 --- a/src/Transformations/LoopEndDoConverter/enddo_loop_converter.h +++ b/src/Transformations/LoopEndDoConverter/enddo_loop_converter.h @@ -1,6 +1,6 @@ #pragma once -#include "../Utils/errors.h" +#include "errors.h" void ConverToEndDo(SgFile *file, std::vector &messagesForFile); std::vector createIfConditions(std::stack& conds, std::stack& ifBlocks, SgStatement *control); diff --git a/src/Transformations/LoopNesting/loop_transform.cpp b/src/Transformations/LoopNesting/loop_transform.cpp index 6679deb..41e4394 100644 --- a/src/Transformations/LoopNesting/loop_transform.cpp +++ b/src/Transformations/LoopNesting/loop_transform.cpp @@ -8,9 +8,9 @@ #include "../DirectiveProcessing/directive_parser.h" #include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h" #include "../SageAnalysisTool/definesValues.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "../SageAnalysisTool/depGraph.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" using std::pair; using std::map; diff --git a/src/Transformations/LoopNesting/loop_transform.h b/src/Transformations/LoopNesting/loop_transform.h index 3713dba..49c5378 100644 --- a/src/Transformations/LoopNesting/loop_transform.h +++ b/src/Transformations/LoopNesting/loop_transform.h @@ -1,7 +1,7 @@ #pragma once #include -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" void reverseCreatedNestedLoops(const std::string &file, std::vector &loopsInFile); bool createNestedLoops(LoopGraph *current, const std::map &depInfoForLoopGraph, diff --git a/src/Transformations/LoopSplitting/loops_splitter.cpp b/src/Transformations/LoopSplitting/loops_splitter.cpp index 09065d7..07d5776 100644 --- a/src/Transformations/LoopSplitting/loops_splitter.cpp +++ b/src/Transformations/LoopSplitting/loops_splitter.cpp @@ -5,7 +5,7 @@ #include "../LoopAnalyzer/loop_analyzer.h" #include "expr_transform.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../CFGraph/CFGraph.h" #include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h" #include "../DirectiveProcessing/directive_parser.h" diff --git a/src/Transformations/LoopSplitting/loops_splitter.h b/src/Transformations/LoopSplitting/loops_splitter.h index 9bdaa5e..084387b 100644 --- a/src/Transformations/LoopSplitting/loops_splitter.h +++ b/src/Transformations/LoopSplitting/loops_splitter.h @@ -4,8 +4,8 @@ #include #include "dvm.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../SageAnalysisTool/depGraph.h" -#include "../Utils/CommonBlock.h" +#include "CommonBlock.h" int splitLoops(SgFile *file, std::vector &loopGraphs, std::vector &messages, const std::map& depInfoForLoopGraph, const std::map& commonBlocks, const std::map>& allFuncInfo, int& countOfTransform); diff --git a/src/Transformations/LoopUnrolling/loops_unrolling.cpp b/src/Transformations/LoopUnrolling/loops_unrolling.cpp index 214c5ab..79fc511 100644 --- a/src/Transformations/LoopUnrolling/loops_unrolling.cpp +++ b/src/Transformations/LoopUnrolling/loops_unrolling.cpp @@ -1,8 +1,8 @@ #include "loops_unrolling.h" #include "../LoopAnalyzer/loop_analyzer.h" -#include "../Utils/errors.h" -#include "../GraphLoop/graph_loops_func.h" +#include "errors.h" +#include "graph_loops_func.h" #include #include diff --git a/src/Transformations/LoopUnrolling/loops_unrolling.h b/src/Transformations/LoopUnrolling/loops_unrolling.h index 4664fcc..f04c2ce 100644 --- a/src/Transformations/LoopUnrolling/loops_unrolling.h +++ b/src/Transformations/LoopUnrolling/loops_unrolling.h @@ -1,7 +1,7 @@ #pragma once #include "dvm.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include int unrollLoops(SgFile* file, std::vector& loopGraph, std::vector& messages); \ No newline at end of file diff --git a/src/Transformations/PrivateArrayRemoving/private_removing.cpp b/src/Transformations/PrivateArrayRemoving/private_removing.cpp index 5589073..0ddd7a6 100644 --- a/src/Transformations/PrivateArrayRemoving/private_removing.cpp +++ b/src/Transformations/PrivateArrayRemoving/private_removing.cpp @@ -1,8 +1,8 @@ #include "private_removing.h" -#include "../Utils/errors.h" -#include "../Utils/SgUtils.h" -#include "../Utils/utils.h" +#include "errors.h" +#include "SgUtils.h" +#include "utils.h" #include "expr_transform.h" #include "../DeadCodeRemoving/dead_code.h" diff --git a/src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp index 25d2766..d2d4a58 100644 --- a/src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp +++ b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp @@ -1,8 +1,8 @@ #include "private_arrays_resizing.h" -#include "../GraphLoop/graph_loops.h" -#include "../Utils/SgUtils.h" -#include "../Utils/utils.h" -#include "../Utils/errors.h" +#include "graph_loops.h" +#include "SgUtils.h" +#include "utils.h" +#include "errors.h" #include "../DirectiveProcessing/directive_parser.h" #include "../LoopAnalyzer/loop_analyzer.h" diff --git a/src/Transformations/PrivateArrayResizing/private_arrays_resizing.h b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.h index 1ad162d..e5f00a3 100644 --- a/src/Transformations/PrivateArrayResizing/private_arrays_resizing.h +++ b/src/Transformations/PrivateArrayResizing/private_arrays_resizing.h @@ -1,5 +1,5 @@ #include "dvm.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include #include #include diff --git a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h index cd5c912..e643f59 100644 --- a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h @@ -1,8 +1,8 @@ #pragma once #include "../ParallelizationRegions/ParRegions.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "SgUtils.h" +#include "errors.h" #include "graph_calls.h" void replaceDistributedArraysInIO(std::vector& regions, diff --git a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp index 20e1d37..4e2480f 100644 --- a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp +++ b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp @@ -13,9 +13,9 @@ #include "dvm.h" #include "../ParallelizationRegions/ParRegions.h" #include "array_assign_to_loop.h" -#include "../Utils/SgUtils.h" +#include "SgUtils.h" #include "expr_transform.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "../VerificationCode/verifications.h" using std::vector; diff --git a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.h b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.h index dade68e..5fc40f3 100644 --- a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.h +++ b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.h @@ -2,7 +2,7 @@ #include #include "dvm.h" -#include "../Utils/errors.h" +#include "errors.h" void convertFromAssignToLoop(SgFile *file, const std::vector& regions, std::vector &messagesForFile, const std::map>& arrayLinksByFuncCalls); void restoreAssignsFromLoop(SgFile *file, const std::map>& arrayLinksByFuncCalls); diff --git a/src/Utils/SgUtils.cpp b/src/Utils/SgUtils.cpp index 51b0dce..5017822 100644 --- a/src/Utils/SgUtils.cpp +++ b/src/Utils/SgUtils.cpp @@ -38,7 +38,7 @@ #include "../Distribution/Distribution.h" #include "graph_calls.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "../CreateInterTree/CreateInterTree.h" #include "../Predictor/PredictScheme.h" #include "../VisualizerCalls/get_information.h" diff --git a/src/Utils/module_utils.cpp b/src/Utils/module_utils.cpp index 9bc9e1a..8d1de0a 100644 --- a/src/Utils/module_utils.cpp +++ b/src/Utils/module_utils.cpp @@ -7,7 +7,7 @@ #include "dvm.h" #include "errors.h" #include "utils.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "module_utils.h" diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index e9f8bcf..dc24ba4 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -25,7 +25,7 @@ #include "errors.h" #include "version.h" -#include "../GraphLoop/graph_loops.h" +#include "graph_loops.h" #include "../Distribution/Array.h" #include "../Distribution/Arrays.h" #include "../DynamicAnalysis/gcov_info.h" diff --git a/src/VerificationCode/CorrectVarDecl.cpp b/src/VerificationCode/CorrectVarDecl.cpp index ccae540..95ea158 100644 --- a/src/VerificationCode/CorrectVarDecl.cpp +++ b/src/VerificationCode/CorrectVarDecl.cpp @@ -10,10 +10,10 @@ #include "dvm.h" #include "verifications.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../ParallelizationRegions/ParRegions.h" -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" using std::vector; using std::string; diff --git a/src/VerificationCode/IncludeChecker.cpp b/src/VerificationCode/IncludeChecker.cpp index 04ad02f..d8caf31 100644 --- a/src/VerificationCode/IncludeChecker.cpp +++ b/src/VerificationCode/IncludeChecker.cpp @@ -8,9 +8,9 @@ #include "dvm.h" #include "verifications.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "utils.h" +#include "SgUtils.h" +#include "errors.h" #include "../Distribution/DvmhDirective.h" using std::vector; diff --git a/src/VerificationCode/StructureChecker.cpp b/src/VerificationCode/StructureChecker.cpp index 1eb17b4..aac7c76 100644 --- a/src/VerificationCode/StructureChecker.cpp +++ b/src/VerificationCode/StructureChecker.cpp @@ -9,9 +9,9 @@ #include "verifications.h" #include "../ParallelizationRegions/ParRegions.h" -#include "../Utils/utils.h" -#include "../Utils/SgUtils.h" -#include "../Utils/errors.h" +#include "utils.h" +#include "SgUtils.h" +#include "errors.h" using std::vector; using std::map; diff --git a/src/VerificationCode/VerifySageStructures.cpp b/src/VerificationCode/VerifySageStructures.cpp index 1056bcc..652fe56 100644 --- a/src/VerificationCode/VerifySageStructures.cpp +++ b/src/VerificationCode/VerifySageStructures.cpp @@ -8,8 +8,8 @@ #include "dvm.h" #include "verifications.h" -#include "../Utils/utils.h" -#include "../Utils/errors.h" +#include "utils.h" +#include "errors.h" int VerifyFile(SgFile *file) { diff --git a/src/VerificationCode/verifications.h b/src/VerificationCode/verifications.h index ae62d4f..af1a3ba 100644 --- a/src/VerificationCode/verifications.h +++ b/src/VerificationCode/verifications.h @@ -4,11 +4,11 @@ #include #include #include "dvm.h" -#include "../Utils/errors.h" +#include "errors.h" #include "../ParallelizationRegions/ParRegions.h" #include "../ParallelizationRegions/ParRegions_func.h" -#include "../Utils/CommonBlock.h" +#include "CommonBlock.h" struct Function { diff --git a/src/VisualizerCalls/BuildGraph.cpp b/src/VisualizerCalls/BuildGraph.cpp index 8519016..bebebb1 100644 --- a/src/VisualizerCalls/BuildGraph.cpp +++ b/src/VisualizerCalls/BuildGraph.cpp @@ -14,7 +14,7 @@ #include #include -#include "../GraphCall/graph_calls_func.h" +#include "graph_calls_func.h" #include "graphLayout/nodesoup.hpp" #include "BuildGraph.h" diff --git a/src/VisualizerCalls/SendMessage.cpp b/src/VisualizerCalls/SendMessage.cpp index 81cabb1..0997195 100644 --- a/src/VisualizerCalls/SendMessage.cpp +++ b/src/VisualizerCalls/SendMessage.cpp @@ -6,7 +6,7 @@ #include #include "SendMessage.h" -#include "../Utils/utils.h" +#include "utils.h" #include "get_information.h" diff --git a/src/VisualizerCalls/get_information.cpp b/src/VisualizerCalls/get_information.cpp index 1e2adf1..d375cd0 100644 --- a/src/VisualizerCalls/get_information.cpp +++ b/src/VisualizerCalls/get_information.cpp @@ -23,14 +23,14 @@ #include #endif -#include "../Utils/errors.h" -#include "../Utils/version.h" +#include "errors.h" +#include "version.h" #include "get_information.h" #include "dvm.h" #include "../Sapfor.h" -#include "../GraphLoop/graph_loops_func.h" -#include "../GraphCall/graph_calls_func.h" -#include "../Utils/utils.h" +#include "graph_loops_func.h" +#include "graph_calls_func.h" +#include "utils.h" #include "../Sapfor.h" #include "../ParallelizationRegions/ParRegions.h" #include "SendMessage.h" From a7764847c408bb27ab80b3aabef41570ce53dcc5 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Jun 2025 13:55:37 +0300 Subject: [PATCH 17/32] fixed --- src/Sapfor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 1106d5f..fdcefed 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2662,7 +2662,7 @@ int main(int argc, char **argv) printStackTrace(); printf("exception occurred\n"); - FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "error_messages.json").c_str(), "w"); + FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "/error_messages.json").c_str(), "w"); if (outF) { json byFileArray = json::array(); From a96a4bcaa67c0a5c793f1adeebea2ffe8e86a2b0 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 4 Jun 2025 15:07:20 +0300 Subject: [PATCH 18/32] added dump messages function --- src/Sapfor.cpp | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index fdcefed..69a9404 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2403,6 +2403,40 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam } } +static void dumpMessages(bool inCatch) +{ + json byFileArray = json::array(); + for (auto& byFile : SPF_messages) + { + json inFile; + inFile["file"] = byFile.first; + + json messages = json::array(); + for (auto& message : byFile.second) + { + if (inCatch) + message.print(byFile.first); + messages.push_back(message.toJson()); + } + inFile["messages"] = messages; + byFileArray.push_back(inFile); + } + json allMessages; + allMessages["allMessages"] = byFileArray; + + const string dump = allMessages.dump().c_str(); + + if (dump.size()) + { + FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "/error_messages.json").c_str(), "w"); + if (outF) + { + fprintf(outF, "%s", dump.c_str()); + fclose(outF); + } + } +} + int main(int argc, char **argv) { int leakMemDump = 0; @@ -2662,35 +2696,12 @@ int main(int argc, char **argv) printStackTrace(); printf("exception occurred\n"); - FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "/error_messages.json").c_str(), "w"); - if (outF) - { - json byFileArray = json::array(); - for (auto& byFile : SPF_messages) - { - json inFile; - inFile["file"] = byFile.first; - - json messages = json::array(); - for (auto& message : byFile.second) - { - message.print(byFile.first); - messages.push_back(message.toJson()); - } - inFile["messages"] = messages; - byFileArray.push_back(inFile); - } - json allMessages; - allMessages["allMessages"] = byFileArray; - - fprintf(outF, "%s", allMessages.dump().c_str()); - fclose(outF); - } + dumpMessages(true); } + dumpMessages(false); deleteAllAllocatedData(withDel); - #if _WIN32 && _DEBUG if (leakMemDump) { From 623898d9132c3f108f87225711c887d30e53cb46 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Thu, 5 Jun 2025 19:04:56 +0300 Subject: [PATCH 19/32] added message dumping for -parse option if running from console --- src/ProjectManipulation/ParseFiles.cpp | 30 ++++++++++++-------- src/Sapfor.cpp | 38 ++------------------------ src/Utils/utils.cpp | 38 ++++++++++++++++++++++++-- src/Utils/utils.h | 3 ++ 4 files changed, 58 insertions(+), 51 deletions(-) diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index 45a68a2..35494f6 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -451,13 +451,6 @@ static int dumpErrors(const vector& listOfProject, const vector splited; splitString(errors[z], '\n', splited); @@ -476,13 +469,22 @@ static int dumpErrors(const vector& listOfProject, const vector #include #include -#include #include #include #include #include -#include -#include "utils.h" #include "errors.h" +#include "utils.h" #include "version.h" #include "graph_loops.h" @@ -1737,4 +1735,38 @@ void copyStringToShort(short*& result, const string& resVal, bool withEnd) if (withEnd) result[resVal.size()] = (short)'\0'; +} + +void dumpMessages(bool inCatch, const map>& messages, const char *vis_path) +{ + json byFileArray = json::array(); + for (auto& byFile : messages) + { + json inFile; + inFile["file"] = byFile.first; + + json messages = json::array(); + for (auto& message : byFile.second) + { + if (inCatch) + message.print(byFile.first); + messages.push_back(message.toJson()); + } + inFile["messages"] = messages; + byFileArray.push_back(inFile); + } + json allMessages; + allMessages["allMessages"] = byFileArray; + + const string dump = allMessages.dump().c_str(); + + if (dump.size()) + { + FILE* outF = fopen((string(vis_path) + "/error_messages.json").c_str(), "w"); + if (outF) + { + fprintf(outF, "%s", dump.c_str()); + fclose(outF); + } + } } \ No newline at end of file diff --git a/src/Utils/utils.h b/src/Utils/utils.h index e96fd1b..77136e4 100644 --- a/src/Utils/utils.h +++ b/src/Utils/utils.h @@ -5,7 +5,9 @@ #include #include +struct Messages; struct DataDirective; + namespace Distribution { class Array; @@ -98,3 +100,4 @@ std::set fillDistributedArraysD(const DataDirective& dataDirective std::set fillDistributedArrays(const DataDirective& dataDirectives, const std::map>& tableOfUniqNamesByArray, const std::map>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false); void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true); +void dumpMessages(bool inCatch, const std::map>& messages, const char* vis_path); From 1895a4b02a8c8d95f1e218a6d08473af3af10a70 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Fri, 6 Jun 2025 08:15:10 +0300 Subject: [PATCH 20/32] fixed --- src/ProjectManipulation/ParseFiles.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index 35494f6..4efb801 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -444,9 +444,8 @@ static int dumpErrors(const vector& listOfProject, const vector Date: Wed, 11 Jun 2025 11:31:48 +0300 Subject: [PATCH 21/32] fixed merging --- src/PrivateAnalyzer/range_structures.cpp | 2 +- src/PrivateAnalyzer/region.cpp | 2 +- .../LoopCombining/loops_combiner.cpp | 15 +-------------- src/Utils/utils.h | 13 +++++++++++++ src/Utils/version.h | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/PrivateAnalyzer/range_structures.cpp b/src/PrivateAnalyzer/range_structures.cpp index 75f2779..80255ab 100644 --- a/src/PrivateAnalyzer/range_structures.cpp +++ b/src/PrivateAnalyzer/range_structures.cpp @@ -2,8 +2,8 @@ #include #include #include -#include +#include "utils.h" #include "range_structures.h" using namespace std; diff --git a/src/PrivateAnalyzer/region.cpp b/src/PrivateAnalyzer/region.cpp index 5030fe3..71fbd22 100644 --- a/src/PrivateAnalyzer/region.cpp +++ b/src/PrivateAnalyzer/region.cpp @@ -146,7 +146,7 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces { auto var = index_vars.back(); int currentVarPos = refPos.back(); - pair currentCoefs = coefsForDims.back(); + pair currentCoefs = coefsForDims.back(); ArrayDimension current_dim; if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST) current_dim = { stoul(var->getValue()), 1, 1 }; diff --git a/src/Transformations/LoopCombining/loops_combiner.cpp b/src/Transformations/LoopCombining/loops_combiner.cpp index 747839a..c0ac86e 100644 --- a/src/Transformations/LoopCombining/loops_combiner.cpp +++ b/src/Transformations/LoopCombining/loops_combiner.cpp @@ -4,6 +4,7 @@ #include "expr_transform.h" #include "errors.h" #include "SgUtils.h" +#include "utils.h" #include #include #include @@ -17,19 +18,6 @@ using std::make_pair; using std::queue; using std::wstring; -static int gcd(int a, int b) -{ - while (a != b) - { - if (a > b) - a = a - b; - else - b = b - a; - } - - return a; -} - static SgSymbol* getLoopSymbol(const LoopGraph* loop) { if (!loop || !loop->isFor) @@ -1385,7 +1373,6 @@ static int getNewStep(SgForStmt* firstLoopStmt, SgForStmt* loopStmt) step2Val = step2->valueInteger(); int stepGcd = gcd(std::abs(step1Val), std::abs(step2Val)); - int newStep = stepGcd; int startDifference = 0; diff --git a/src/Utils/utils.h b/src/Utils/utils.h index 77136e4..fc2611f 100644 --- a/src/Utils/utils.h +++ b/src/Utils/utils.h @@ -101,3 +101,16 @@ std::set fillDistributedArrays(const DataDirective& dataDirectives, void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true); void dumpMessages(bool inCatch, const std::map>& messages, const char* vis_path); + +template +inline T gcd(T a, T b) +{ + while (a != b) + { + if (a > b) + a = a - b; + else + b = b - a; + } + return a; +} diff --git a/src/Utils/version.h b/src/Utils/version.h index 6f49767..4f8972a 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2423" +#define VERSION_SPF "2424" From 622159cba6b235ab52a460b9f044d35cb2465105 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 11 Jun 2025 15:07:06 +0300 Subject: [PATCH 22/32] improved --- src/CFGraph/CFGraph.cpp | 2 +- src/ProjectParameters/projectParameters.cpp | 5 +++-- src/Sapfor.cpp | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CFGraph/CFGraph.cpp b/src/CFGraph/CFGraph.cpp index 749eac3..6fc4682 100644 --- a/src/CFGraph/CFGraph.cpp +++ b/src/CFGraph/CFGraph.cpp @@ -1156,7 +1156,7 @@ map> buildCFG(const map& common SAPFOR::buildDominatorTree(bblocks); auto msec = duration_cast(high_resolution_clock::now() - t).count(); - __spf_print(1, "dominator build time is %.3f sec\n", msec / 1000.); + __spf_print(1, " dominator build time is %.3f sec\n", msec / 1000.); } if (SgFile::switchToFile(oldFile) == -1) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 30e21f2..6de6861 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -429,10 +429,11 @@ void findParameters(ResultSet& foundParameters, toAdd->setFileId(stmt_before->getFileId()); toAdd->setProject(stmt_before->getProject()); - if (mode == MODE::AFTER) + //NOTE: only for debbuging, results will be transferred to the visualizer + /*if (mode == MODE::AFTER) stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent()); else - stmt_before->insertStmtBefore(*toAdd, *stmt_before->controlParent()); + stmt_before->insertStmtBefore(*toAdd, *stmt_before->controlParent());*/ foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name)); } diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 8e2ed3e..961964f 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2373,7 +2373,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case LOOPS_COMBINER: case FIX_COMMON_BLOCKS: case TEST_PASS: - case FIND_PARAMETERS: case SET_IMPLICIT_NONE: runAnalysis(*project, curr_regime, false); case SUBST_EXPR_RD_AND_UNPARSE: From a0704038db25f1bb4091905afee21d7c92340885 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 11 Jun 2025 15:17:32 +0300 Subject: [PATCH 23/32] fixed compilation --- src/ProjectParameters/projectParameters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ProjectParameters/projectParameters.cpp b/src/ProjectParameters/projectParameters.cpp index 6de6861..eef70c8 100644 --- a/src/ProjectParameters/projectParameters.cpp +++ b/src/ProjectParameters/projectParameters.cpp @@ -40,6 +40,9 @@ enum class MODE AFTER }; +template +static void extract_vars_from_reg(set& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr); + static tuple stmtToIR(const map>& CFGraph, SgStatement* stmt) { From 10636427edbf36c6e16b1f26a982eea28a134cd0 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 12:20:34 +0300 Subject: [PATCH 24/32] fixed findArrayRef in loop_graph --- src/GraphLoop/graph_loops.cpp | 2 +- src/Utils/SgUtils.cpp | 2 ++ src/Utils/version.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GraphLoop/graph_loops.cpp b/src/GraphLoop/graph_loops.cpp index 16438ee..e35ae5c 100644 --- a/src/GraphLoop/graph_loops.cpp +++ b/src/GraphLoop/graph_loops.cpp @@ -520,7 +520,7 @@ static void findArrayRef(SgExpression *exp, bool isWirte, set& use { if (exp) { - if (exp->variant() == ARRAY_REF) + if (isArrayRef(exp)) { DIST::Array *arrayRef = NULL; SgSymbol *symbS = OriginalSymbol(exp->symbol()); diff --git a/src/Utils/SgUtils.cpp b/src/Utils/SgUtils.cpp index 5017822..1a206c5 100644 --- a/src/Utils/SgUtils.cpp +++ b/src/Utils/SgUtils.cpp @@ -3219,12 +3219,14 @@ bool isArrayRef(SgExpression* ex) { SgArrayRefExp* arrayRef = isSgArrayRefExp(ex); if (arrayRef) + { if (isArrayType(ex->symbol()->type())) { auto type = isSgArrayType(ex->symbol()->type()); if (type && type->dimension()) return true; } + } } return false; } diff --git a/src/Utils/version.h b/src/Utils/version.h index ad1744c..37ca275 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2425" +#define VERSION_SPF "2426" From 9e777ceeaba43742afdddb39c51947bac66050bf Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 12:50:04 +0300 Subject: [PATCH 25/32] fixed shared memory parallelization, moved messages to single file --- src/Distribution/Distribution.cpp | 22 +--- src/Distribution/GraphCSR.cpp | 8 +- src/LoopAnalyzer/loop_analyzer.cpp | 21 +--- src/ProjectManipulation/ParseFiles.cpp | 14 +-- src/Sapfor.cpp | 16 +-- .../FunctionInlining/inliner.cpp | 7 +- src/VisualizerCalls/SendMessage.cpp | 110 +++++++++++++++++- src/VisualizerCalls/SendMessage.h | 5 +- 8 files changed, 133 insertions(+), 70 deletions(-) diff --git a/src/Distribution/Distribution.cpp b/src/Distribution/Distribution.cpp index 1ff6149..64b56d5 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -455,15 +455,7 @@ namespace Distribution } if (needPrint) - { -#if _WIN32 - wstring treeM = L"разрешение конфликтов, обработка группы " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size()); -#else - wstring treeM = L"conflict resolution, processing group " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size()); -#endif - sendMessage_2lvl(treeM); - - } + sendMessage_2lvl(4, k, (int)AllCycles.size()); auto timeR = steady_clock::now(); if (countConflicts != 0) @@ -516,7 +508,7 @@ namespace Distribution } if (needPrint) - sendMessage_2lvl(L""); + sendMessage_2lvl(2); return make_pair(allOnlySecondType, globalSum); } @@ -572,13 +564,7 @@ namespace Distribution for (int z = 0; z < arraysV.size(); ++z) { const DIST::Array *array = arraysV[z]; - -#ifdef _WIN32 - wstring treeM = L"разрешение конфликтов, обработка массива " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size()); -#else - wstring treeM = L"conflict resolution, processing array " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size()); -#endif - sendMessage_2lvl(treeM); + sendMessage_2lvl(5, z, (int)arrays.size()); vector verts; @@ -605,7 +591,7 @@ namespace Distribution } } } - sendMessage_2lvl(L""); + sendMessage_2lvl(2); } else { diff --git a/src/Distribution/GraphCSR.cpp b/src/Distribution/GraphCSR.cpp index 1890479..9d17db0 100644 --- a/src/Distribution/GraphCSR.cpp +++ b/src/Distribution/GraphCSR.cpp @@ -830,13 +830,13 @@ namespace Distribution color[k] = WHITE; findFrom = currentV; -#ifdef _WIN32 +/*#ifdef _WIN32 if (needPrint) { wstring vertexM = std::to_wstring(k + 1) + L"/" + std::to_wstring(vertByTrees[t].size()); sendMessage_2lvl(wstring(L"поиск простых циклов в графе, обработка дерева ") + wstring(treeM.begin(), treeM.end()) + L" вершины " + wstring(vertexM.begin(), vertexM.end())); } -#endif +#endif*/ __spf_print(PRINT_TIMES && needPrint, "v (tree %d) = %d (with neighb %d) ", t, i, neighbors[i + 1] - neighbors[i]); activeV[activeCounter++] = currentV; FindLoop(cyclesTmp[t], currentV, currentV, numbers); @@ -847,8 +847,8 @@ namespace Distribution maxLoopDim = wasMaxLoopDim; } - if (needPrint) - sendMessage_2lvl(L""); + /*if (needPrint) + sendMessage_2lvl(2);*/ } catch (int code) { diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index cdbbc7d..dd312bf 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -1633,17 +1633,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); -#if _WIN32 - if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'"); - else - sendMessage_2lvl(wstring(L"обработка модуля '") + wstring(fName.begin(), fName.end()) + L"'"); -#else - if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); - else - sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'"); -#endif + sendMessage_2lvl(0, (file->functions(i)->variant() != MODULE_STMT), fName); set delcsSymbViewed; set delcsStatViewed; @@ -2188,11 +2178,8 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); -#else - sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); -#endif + sendMessage_2lvl(1, idx, (int)convertedLoopInfo.size()); + tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace); } } @@ -2340,7 +2327,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, map parseList(vector& listOfProject, } } -#ifdef _WIN32 - sendMessage_2lvl(L" обработка файла '" + to_wstring(file) + L"'"); -#else - sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'"); -#endif + sendMessage_2lvl(3, file); + StdCapture::Init(); string errorMessage = ""; try @@ -578,11 +575,8 @@ static void parseFiles(int& iters, vector& errors, vector& lis do { -#ifdef _WIN32 - sendMessage_1lvl(L"выполняется " + std::to_wstring((iters + 1)) + L" итерация синтаксического анализа"); -#else - sendMessage_1lvl(L"running " + std::to_wstring((iters + 1)) + L" iteration of syntax analisys"); -#endif + sendMessage_1lvl(0, iters + 1); + errors = parseList(listOfProject, iters != 0, parseForInlining, mapModuleDeps, moduleDelc, modDirectOrder, isFromConsole); changed = createMapOfUse(errors, listOfProject, mapModuleDeps); if (iters != 0) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 961964f..24f4a77 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -398,11 +398,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne __spf_print(DEBUG_LVL1, "RUN PASS with name %s\n", passNames[curr_regime]); auto toSendStrMessage = string(passNames[curr_regime]); -#ifdef _WIN32 - sendMessage_1lvl(wstring(L"выполняется РїСЂРѕС…РѕРґ '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#else - sendMessage_1lvl(wstring(L"running pass '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#endif + sendMessage_1lvl(1, toSendStrMessage); const int n = project.numberOfFiles(); bool verifyOK = true; @@ -450,11 +446,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne SgFile *file = &(project.file(i)); toSendStrMessage = file->filename(); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"обработка файла '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#else - sendMessage_2lvl(wstring(L"processing file '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#endif + sendMessage_2lvl(3, toSendStrMessage); sendMessage_progress(std::to_wstring((int)(((double)(n - i) / n) * 100))); const char *file_name = file->filename(); @@ -1057,7 +1049,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne throw -11; } - sendMessage_2lvl(wstring(L"")); + sendMessage_2lvl(2); // ********************************** /// /// SECOND AGGREGATION STEP /// // ********************************** /// @@ -1928,7 +1920,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne const float elapsedGlobal = duration_cast(high_resolution_clock::now() - globalTime).count() / 1000.; __spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal); - sendMessage_2lvl(wstring(L"")); + sendMessage_2lvl(2); if (internalExit != 0) throw -1; diff --git a/src/Transformations/FunctionInlining/inliner.cpp b/src/Transformations/FunctionInlining/inliner.cpp index 209cffd..bb3231d 100644 --- a/src/Transformations/FunctionInlining/inliner.cpp +++ b/src/Transformations/FunctionInlining/inliner.cpp @@ -1776,11 +1776,8 @@ static bool inliner(const string& fileName_in, const string& funcName, const int point.currCall = func->funcName; __spf_print(1, " INLINE %s - ", func->funcName.c_str()); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"подстановка функции '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'"); -#else - sendMessage_2lvl(wstring(L"inlinig of function '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'"); -#endif + sendMessage_2lvl(6, func->funcName); + //1 level bool isInlined = run_inliner(funcMap, toInsert, SPF_messages, fileName, func, newSymbsToDeclare, point, commonBlocks); __spf_print(1, "%s\n", isInlined ? "done" : "fault"); diff --git a/src/VisualizerCalls/SendMessage.cpp b/src/VisualizerCalls/SendMessage.cpp index 0997195..068e9fe 100644 --- a/src/VisualizerCalls/SendMessage.cpp +++ b/src/VisualizerCalls/SendMessage.cpp @@ -144,10 +144,116 @@ static int decodeMessage(const string& message, vector& pars, int &winH, return 0; } -void sendMessage_1lvl(const wstring& toSend) { MessageManager::sendFirstLvl (toSend); } -void sendMessage_2lvl(const wstring& toSend) { MessageManager::sendSecondLvl(toSend); } +static void sendMessage_1lvl(const wstring& toSend) { MessageManager::sendFirstLvl (toSend); } +static void sendMessage_2lvl(const wstring& toSend) { MessageManager::sendSecondLvl(toSend); } void sendMessage_progress(const wstring& toSend) { MessageManager::sendProgress (toSend); } +void sendMessage_1lvl(int kind, ...) +{ + va_list list; + va_start(list, kind); + + if (kind == 0) + { + int iters = va_arg(list, int); +#ifdef _WIN32 + sendMessage_1lvl(L"выполняется " + std::to_wstring(iters) + L" итерация синтаксического анализа"); +#else + sendMessage_1lvl(L"running " + std::to_wstring(iters) + L" iteration of syntax analisys"); +#endif + } + else if (kind == 1) + { + string str = va_arg(list, string); +#ifdef _WIN32 + sendMessage_1lvl(wstring(L"выполняется проход '") + wstring(str.begin(), str.end()) + L"'"); +#else + sendMessage_1lvl(wstring(L"running pass '") + wstring(str.begin(), str.end()) + L"'"); +#endif + } + + va_end(list); +} + +void sendMessage_2lvl(int kind, ...) +{ + va_list list; + va_start(list, kind); + + if (kind == 0) + { + bool isFunction = va_arg(list, int); + string fName = va_arg(list, string); +#if _WIN32 + if (isFunction) + sendMessage_2lvl(wstring(L"обработка функции '") + to_wstring(fName) + L"'"); + else + sendMessage_2lvl(wstring(L"обработка модуля '") + to_wstring(fName) + L"'"); +#else + if (isFunction) + sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); + else + sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'"); +#endif + } + else if (kind == 1) + { + int idx = va_arg(list, int); + int all = va_arg(list, int); +#ifdef _WIN32 + sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(all)); +#else + sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(all)); +#endif + } + else if (kind == 2) + { + sendMessage_2lvl(L""); + } + else if (kind == 3) + { + string file = va_arg(list, string); +#ifdef _WIN32 + sendMessage_2lvl(L" обработка файла '" + to_wstring(file) + L"'"); +#else + sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'"); +#endif + } + else if (kind == 4) + { + int k = va_arg(list, int); + int all = va_arg(list, int); +#if _WIN32 + wstring treeM = L"разрешение конфликтов, обработка группы " + std::to_wstring(k + 1) + L"/" + std::to_wstring(all); +#else + wstring treeM = L"conflict resolution, processing group " + std::to_wstring(k + 1) + L"/" + std::to_wstring(all); +#endif + sendMessage_2lvl(treeM); + } + else if (kind == 5) + { + int z = va_arg(list, int); + int all = va_arg(list, int); +#ifdef _WIN32 + wstring treeM = L"разрешение конфликтов, обработка массива " + std::to_wstring(z + 1) + L"/" + std::to_wstring(all); +#else + wstring treeM = L"conflict resolution, processing array " + std::to_wstring(z + 1) + L"/" + std::to_wstring(all); +#endif + sendMessage_2lvl(treeM); + } + else if (kind == 6) + { + string funcName = va_arg(list, string); +#ifdef _WIN32 + sendMessage_2lvl(wstring(L"подстановка функции '") + to_wstring(funcName) + L"'"); +#else + sendMessage_2lvl(wstring(L"inlinig of function '") + to_wstring(funcName) + L"'"); +#endif + } + + va_end(list); +} + static string utf8_encode(const wstring& wstr) { if (wstr.empty()) diff --git a/src/VisualizerCalls/SendMessage.h b/src/VisualizerCalls/SendMessage.h index aa3bbba..eeb583b 100644 --- a/src/VisualizerCalls/SendMessage.h +++ b/src/VisualizerCalls/SendMessage.h @@ -32,7 +32,8 @@ public: static int init(); }; -void sendMessage_1lvl(const std::wstring& toSend); -void sendMessage_2lvl(const std::wstring& toSend); +void sendMessage_1lvl(int kind, ...); +void sendMessage_2lvl(int kind, ...); void sendMessage_progress(const std::wstring& toSend); + unsigned int GetPid(); From 6a59bc0e09c4c9b8ca94d5d5a31bfb228cadb7bd Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 12:52:57 +0300 Subject: [PATCH 26/32] added missing --- src/VisualizerCalls/SendMessage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VisualizerCalls/SendMessage.cpp b/src/VisualizerCalls/SendMessage.cpp index 068e9fe..5ac7364 100644 --- a/src/VisualizerCalls/SendMessage.cpp +++ b/src/VisualizerCalls/SendMessage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "SendMessage.h" #include "utils.h" From 50dd54cec1eb86e327de9c7ab7b1f256ba213b6b Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 15:15:51 +0300 Subject: [PATCH 27/32] improved --- .../VectorAssignToLoop/array_assign_to_loop.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp index 4e2480f..927d661 100644 --- a/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp +++ b/src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp @@ -2215,6 +2215,7 @@ void restoreAssignsFromLoop(SgFile* file, const mapsetVariant(-abs(move.first->variant())); + __spf_print(1, " save assign\n"); if (needDecl) // declare loops symbol { @@ -2237,8 +2238,10 @@ void restoreAssignsFromLoop(SgFile* file, const mapsetVariant(-abs(move.second->variant())); + __spf_print(1, " restored assign\n"); + } } } } From 0eee7998673abab72ccb0e44b34e617bdc2d0345 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 16:03:14 +0300 Subject: [PATCH 28/32] fixed dependencies pass order --- src/Utils/PassManager.h | 2 +- src/Utils/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/PassManager.h b/src/Utils/PassManager.h index 482b949..24b591a 100644 --- a/src/Utils/PassManager.h +++ b/src/Utils/PassManager.h @@ -257,7 +257,7 @@ void InitPassesDependencies(map> &passDepsIn, set list({ REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN }) <= Pass(RESOLVE_PAR_REGIONS); - list({ REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN, FILL_PAR_REGIONS}) <= Pass(REMOVE_DIST_ARRAYS_FROM_IO); + list({ FILL_PAR_REGIONS, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN }) <= Pass(REMOVE_DIST_ARRAYS_FROM_IO); Pass(REVERT_SUBST_EXPR_RD) <= Pass(EXPAND_EXTRACT_PAR_REGION); diff --git a/src/Utils/version.h b/src/Utils/version.h index 37ca275..bde3fc6 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2426" +#define VERSION_SPF "2427" From ebc5a1cbc158ba7c677314bba80b779b24d59375 Mon Sep 17 00:00:00 2001 From: xnpster Date: Sat, 14 Jun 2025 20:18:59 +0300 Subject: [PATCH 29/32] REMOVE_DIST_ARRAYS_FROM_IO: use isArrayRef --- .../ReplaceArraysInIO/replace_dist_arrays_in_io.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp index e9c088d..f73e7c1 100644 --- a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp @@ -136,7 +136,8 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* e if (!exp) return; - if (exp->symbol() && exp->symbol()->identifier() && strcmp(exp->symbol()->identifier(), arr->identifier()) == 0) + if (isArrayRef(exp) && + strcmp(exp->symbol()->identifier(), arr->identifier()) == 0) { has_read |= from_read; has_write |= from_write; From fc47a1685c989e9e9bac8366bb410071beb43904 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sat, 14 Jun 2025 21:07:24 +0300 Subject: [PATCH 30/32] version updated --- src/Utils/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/version.h b/src/Utils/version.h index bde3fc6..4fc4e20 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2427" +#define VERSION_SPF "2428" From f5f99f6e8a8825d138d3433c3a7cab8c25892cdf Mon Sep 17 00:00:00 2001 From: xnpster Date: Sun, 15 Jun 2025 15:08:11 +0300 Subject: [PATCH 31/32] REMOVE_DIST_ARRAYS_FROM_IO: improve parsing of IO operators, fix substitution borders --- .../replace_dist_arrays_in_io.cpp | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp index f73e7c1..9a1ad21 100644 --- a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp @@ -88,24 +88,36 @@ static void populateDistributedIoArrays(map>& array case READ_STAT: case WRITE_STAT: { - SgExpression* spec = stat->expr(1); - __spf_print(DEBUG_TRACE, "[%d: %s (%d)]\n", 2000, spec->rhs()->unparse(), spec->rhs()->variant()); - if (!spec || spec->variant() != EXPR_LIST || - spec->lhs()->variant() != SPEC_PAIR || - !spec->rhs() || !spec->rhs()->lhs() || spec->rhs()->lhs()->variant() != SPEC_PAIR) + + if (spec->variant() == SPEC_PAIR) { - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - return; + if (spec->rhs()->variant() != KEYWORD_VAL || spec->rhs()->sunparse() != "*") + { + need_replace = true; + break; + } } + else + { + while (spec) + { + auto *kv = spec->lhs(); + if (!kv || kv->variant() != SPEC_PAIR || !kv->rhs()) + { + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + return; + } - SgExpression* unit_val = spec->lhs()->rhs(), * fmt_val = spec->rhs()->lhs()->rhs(); + if (kv->rhs()->variant() != KEYWORD_VAL || kv->rhs()->sunparse() != "*") + { + need_replace = true; + break; + } - if (unit_val->variant() != KEYWORD_VAL || unit_val->sunparse() != "*" || - fmt_val->variant() != KEYWORD_VAL || fmt_val->sunparse() != "*") - need_replace = true; - - break; + spec = spec->rhs(); + } + } } default: break; @@ -203,11 +215,9 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace while (start->lexNext() && !isSgExecutableStatement(start->lexNext())) start = start->lexNext(); - auto* stop = last->lexNext(); - bool has_read = false, has_write = false; - for (auto* st = start->lexNext(); st && st != stop->lexPrev(); st = st->lexNext()) + for (auto* st = start->lexNext(); st && st != last; st = st->lexNext()) replaceArrayRec(replace_symb, replace_by, st, has_read, has_write); From 537f3eb6e92e1e1988f3eaafde73c7942685427d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 15 Jun 2025 20:06:35 +0300 Subject: [PATCH 32/32] version updated --- src/Utils/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/version.h b/src/Utils/version.h index 4fc4e20..7465e56 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2428" +#define VERSION_SPF "2429"