fix removals from passes' dependencies
This commit is contained in:
@@ -2324,7 +2324,7 @@ static void findFunctionsToInclude(bool needToAddErrors)
|
||||
|
||||
static bool dvmInited = false;
|
||||
|
||||
void runPass(const int curr_regime, const char *proj_name, const char *folderName)
|
||||
void runPass(const int curr_regime, const char *proj_name, const char *folderName, bool root_call)
|
||||
{
|
||||
// create full dependency graph
|
||||
switch (curr_regime)
|
||||
@@ -2336,11 +2336,14 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
}
|
||||
|
||||
// init math functions of FORTRAN
|
||||
if(root_call)
|
||||
{
|
||||
initIntrinsicFunctionNames();
|
||||
initTags();
|
||||
InitPassesDependencies(passesDependencies, passesIgnoreStateDone);
|
||||
removalsFromPassesDependencies(passesDependencies);
|
||||
removalsFromPassesDependencies(passesDependencies, curr_regime);
|
||||
setPassValues();
|
||||
}
|
||||
|
||||
if (dvmInited == false)
|
||||
{
|
||||
@@ -2933,9 +2936,9 @@ int main(int argc, char **argv)
|
||||
if (curr_regime == EMPTY_PASS)
|
||||
printHelp(passNames, printPasses ? EMPTY_PASS : -1);
|
||||
|
||||
runPass(curr_regime, proj_name, folderName);
|
||||
runPass(curr_regime, proj_name, folderName, true);
|
||||
if (printText)
|
||||
runPass(UNPARSE_FILE, proj_name, folderName);
|
||||
runPass(UNPARSE_FILE, proj_name, folderName, true);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
||||
@@ -350,4 +350,4 @@ static int getPassCode(const std::string& passName)
|
||||
return z;
|
||||
return -1;
|
||||
}
|
||||
void runPass(const int curr_regime, const char *proj_name = "dvm.proj", const char *folderName = NULL);
|
||||
void runPass(const int curr_regime, const char *proj_name = "dvm.proj", const char *folderName = NULL, bool root_call = false);
|
||||
|
||||
@@ -12,6 +12,7 @@ using std::set;
|
||||
#define list vector<Pass>
|
||||
|
||||
static map<passes, vector<passes>> *passDeps;
|
||||
static map<passes, set<passes>> passRemovals;
|
||||
|
||||
class Pass
|
||||
{
|
||||
@@ -72,40 +73,13 @@ public:
|
||||
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<passes> to_erase;
|
||||
|
||||
for(const auto& remove_pass : right_vec)
|
||||
to_erase.insert(remove_pass.name);
|
||||
for(const auto& left : left_vec)
|
||||
{
|
||||
auto& eraseFrom = passRemovals[left.name];
|
||||
|
||||
set<passes> to_process, processed;
|
||||
|
||||
for (const auto& process_pass : left_vec)
|
||||
to_process.insert(process_pass.name);
|
||||
|
||||
while (!to_process.empty()) {
|
||||
set<passes> 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;
|
||||
for(const auto& right : right_vec)
|
||||
eraseFrom.insert(right.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +98,35 @@ public:
|
||||
list({ *this }) -= list({ right });
|
||||
}
|
||||
|
||||
void applyRemovals() {
|
||||
set<passes> to_process = { name }, processed;
|
||||
|
||||
while (!to_process.empty())
|
||||
{
|
||||
set<passes> to_process_next;
|
||||
|
||||
for (const auto& pass : to_process) {
|
||||
if (processed.insert(pass).second) {
|
||||
auto removals_it = passRemovals.find(pass);
|
||||
auto deps_it = passDeps->find(pass);
|
||||
|
||||
if (removals_it != passRemovals.end() && deps_it != passDeps->end()) {
|
||||
auto& removals = removals_it->second;
|
||||
auto& deps = deps_it->second;
|
||||
for (auto dep_it = deps.begin(); dep_it != deps.end();) {
|
||||
if (removals.find(*dep_it) == removals.end())
|
||||
to_process_next.insert(*(dep_it++));
|
||||
else
|
||||
dep_it = deps.erase(dep_it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
to_process = to_process_next;
|
||||
}
|
||||
}
|
||||
|
||||
Pass(passes name) : name(name) { }
|
||||
};
|
||||
|
||||
@@ -148,8 +151,7 @@ static void depsToGraphViz(const map<passes, vector<passes>> &passDepsIn)
|
||||
|
||||
void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes> &passesIgnoreStateDone, bool printTree = false)
|
||||
{
|
||||
if (passDepsIn.size() != 0)
|
||||
return;
|
||||
passDepsIn.clear();
|
||||
|
||||
passDeps = &passDepsIn;
|
||||
|
||||
@@ -272,8 +274,10 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
}
|
||||
}
|
||||
|
||||
void removalsFromPassesDependencies(map<passes, vector<passes>>& passDepsIn)
|
||||
void removalsFromPassesDependencies(map<passes, vector<passes>>& passDepsIn, const int curr_regime)
|
||||
{
|
||||
Pass(INSERT_PARALLEL_DIRS_NODIST) -= list({ FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE });
|
||||
|
||||
Pass(passes(curr_regime)).applyRemovals();
|
||||
}
|
||||
#undef list
|
||||
|
||||
Reference in New Issue
Block a user