Merge branch 'master' into analyze_loops_with_IR
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#include "DvmhRegions/LoopChecker.h"
|
||||
#include "DvmhRegions/ReadWriteAnalyzer.h"
|
||||
#include "Utils/utils.h"
|
||||
#include "Utils/json.hpp"
|
||||
#include "Distribution/Array.h"
|
||||
|
||||
#include "VisualizerCalls/get_information.h"
|
||||
@@ -108,6 +109,7 @@ using namespace std;
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::milliseconds;
|
||||
using json = nlohmann::json;
|
||||
|
||||
int PASSES_DONE[EMPTY_PASS];
|
||||
bool PASSES_DONE_INIT = false;
|
||||
@@ -332,9 +334,10 @@ static string unparseProjectIfNeed(SgFile* file, const int curr_regime, const bo
|
||||
unparseToBuf = removeIncludeStatsAndUnparse(file, file_name, fout_name.c_str(), allIncludeFiles, out_free_form == 1, moduleUsesByFile,
|
||||
moduleDecls, getObjectForFileFromMap(file_name, exctactedModuleStats), toString, false, true);
|
||||
auto itI = filesToInclude.find(file_name);
|
||||
for (auto& incl : itI->second)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
for (auto& [_, incls] : itI->second)
|
||||
for (auto& incl : incls)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -828,20 +831,27 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
auto fileIt = includeDependencies.find(file_name);
|
||||
if (fileIt == includeDependencies.end())
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, set<string>()));
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, map<int, set<string>>()));
|
||||
|
||||
set<string> modFiles;
|
||||
for (auto& elem : moduleDecls)
|
||||
modFiles.insert(elem.second);
|
||||
|
||||
for (SgStatement *first = file->firstStatement(); first; first = first->lexNext())
|
||||
SgStatement* lastFromFile = NULL;
|
||||
for (SgStatement *st = file->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
if (strcmp(file_name, first->fileName()))
|
||||
if (st->variant() == MODULE_STMT && modFiles.find(st->fileName()) != modFiles.end())
|
||||
st = st->lastNodeOfStmt();
|
||||
else
|
||||
{
|
||||
if (first->variant() == MODULE_STMT && modFiles.find(first->fileName()) != modFiles.end())
|
||||
first = first->lastNodeOfStmt();
|
||||
if (strcmp(file_name, st->fileName()))
|
||||
{
|
||||
if (lastFromFile == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fileIt->second[lastFromFile->lineNumber()].insert(st->fileName());
|
||||
}
|
||||
else
|
||||
fileIt->second.insert(first->fileName());
|
||||
lastFromFile = st;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1573,6 +1583,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
if (keepFiles)
|
||||
printLoopGraph("_loopGraph.txt", loopGraph);
|
||||
//printf("%s\n", convertToJson(loopGraph).dump(2).c_str());
|
||||
}
|
||||
else if (curr_regime == FILL_COMMON_BLOCKS)
|
||||
{
|
||||
@@ -1607,12 +1618,15 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<string> includedToThisFile;
|
||||
if (itDep != includeDependencies.end())
|
||||
{
|
||||
for (auto &inclDep : itDep->second)
|
||||
for (auto& [_, incls] : itDep->second)
|
||||
{
|
||||
auto comm = commentsToInclude.find(inclDep);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto &allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
for (auto& incl : incls)
|
||||
{
|
||||
auto comm = commentsToInclude.find(incl);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto& allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2046,7 +2060,7 @@ static void findFunctionsToInclude(bool needToAddErrors)
|
||||
SPF_messages[byFile.first].push_back(message);
|
||||
else
|
||||
{
|
||||
if (message.type != ERROR)
|
||||
if (message.getType() != ERROR)
|
||||
SPF_messages[byFile.first].push_back(message);
|
||||
else
|
||||
lastErrors[byFile.first].push_back(message);
|
||||
@@ -2221,8 +2235,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName);
|
||||
|
||||
runAnalysis(*project, CALCULATE_STATS_SCHEME, false);
|
||||
for (auto& elem : allPredictorStats)
|
||||
__spf_print(1, " stat for file %s: %s\n", elem.first.c_str(), elem.second.to_string().c_str());
|
||||
|
||||
//TODO: need to rewrite this to new algo
|
||||
/*if (!folderName && !consoleMode || predictOn)
|
||||
runAnalysis(*project, PREDICT_SCHEME, false); */
|
||||
@@ -2390,7 +2403,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
break;
|
||||
case PARSE_FILES:
|
||||
{
|
||||
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining);
|
||||
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining, SPF_messages);
|
||||
if (err != 0)
|
||||
throw err;
|
||||
}
|
||||
@@ -2659,26 +2672,28 @@ int main(int argc, char **argv)
|
||||
{
|
||||
printStackTrace();
|
||||
printf("exception occurred\n");
|
||||
|
||||
json byFileArray = json::array();
|
||||
for (auto& byFile : SPF_messages)
|
||||
{
|
||||
json inFile;
|
||||
inFile["file"] = byFile.first;
|
||||
|
||||
json messages = json::array();
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
string toPrint = "";
|
||||
for (int z = 0; z < message.engMessage.size(); ++z)
|
||||
toPrint += message.engMessage[z];
|
||||
string type;
|
||||
if (message.type == WARR)
|
||||
type = "WARR";
|
||||
else if (message.type == ERROR)
|
||||
type = "ERROR";
|
||||
else if (message.type == NOTE)
|
||||
type = "NOTE";
|
||||
else
|
||||
type = "UNKN";
|
||||
|
||||
printf("%s - [#%d: %s: line %d]: %s\n", type.c_str(), message.group, byFile.first.c_str(), message.line, toPrint.c_str());
|
||||
message.print(byFile.first);
|
||||
messages.push_back(message.toJson());
|
||||
}
|
||||
inFile["messages"] = messages;
|
||||
byFileArray.push_back(inFile);
|
||||
}
|
||||
json allMessages;
|
||||
allMessages["allMessage"] = byFileArray;
|
||||
|
||||
FILE* outF = fopen("dump_messages.json", "w");
|
||||
fprintf(outF, "%s", allMessages.dump().c_str());
|
||||
fclose(outF);
|
||||
}
|
||||
|
||||
deleteAllAllocatedData(withDel);
|
||||
|
||||
Reference in New Issue
Block a user