From aae81c0e8790d98812d8804314cc22a62965b6ce Mon Sep 17 00:00:00 2001 From: mkoch Date: Thu, 7 Sep 2023 17:42:40 +0300 Subject: [PATCH] PassManager: -= operator added, FIND_FUNC_TO_INCLUDE and CHECK_FUNC_TO_INCLUDE removed from INSERT_PARALLEL_DIRS_NODIST --- .../Sapfor_2017/_src/Utils/PassManager.h | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h index f890cc4..8906ee5 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h @@ -69,6 +69,61 @@ public: return right_vec; } + friend void operator-=(const list& left_vec, const list& right_vec) + { + /* erase each pass in right_vec from dependency tree for each pass in left_vec */ + set to_erase; + + for(const auto& remove_pass : right_vec) + to_erase.insert(remove_pass.name); + + set to_process, processed; + + for (const auto& process_pass : left_vec) + to_process.insert(process_pass.name); + + while (!to_process.empty()) { + set next_to_process; + + for (const auto& pass_name : to_process) { + processed.insert(pass_name); + auto pass_deps = (*passDeps).find(pass_name); + if (pass_deps != (*passDeps).end()) { + for (auto dep = pass_deps->second.begin(); dep != pass_deps->second.end();) { + if (to_erase.find(*dep) != to_erase.end()) { + dep = pass_deps->second.erase(dep); + } + else { + if (processed.find(*dep) == processed.end()) + next_to_process.insert(*dep); + dep++; + } + } + + if(pass_deps->second.empty()) + pass_deps = (*passDeps).erase(pass_deps); + } + } + + to_process = next_to_process; + } + } + + friend void operator-=(const list& left_vec, const Pass& right) + { + left_vec -= list({right}); + } + + void operator-=(const list& right_vec) const + { + list({ *this }) -= right_vec; + } + + void operator-=(const Pass& right) const + { + list({ *this }) -= list({ right }); + } + Pass(passes name) : name(name) { } }; @@ -98,6 +153,8 @@ void InitPassesDependencies(map> &passDepsIn, set passDeps = &passDepsIn; + /* Insertions */ + Pass(PREPROC_SPF) <= Pass(CREATE_INTER_TREE); list({ CREATE_INTER_TREE, CORRECT_VAR_DECL }) << list({ GCOV_PARSER, PREDICT_SCHEME, INSERT_INTER_TREE }); @@ -200,6 +257,10 @@ void InitPassesDependencies(map> &passDepsIn, set Pass(CALL_GRAPH2) <= Pass(FIX_COMMON_BLOCKS); + /* Removals */ + + Pass(INSERT_PARALLEL_DIRS_NODIST) -= list({ FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE }); + passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS, EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW, REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,