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