diff --git a/DiscoPoP/DiscoPoP.cpp b/DiscoPoP/DiscoPoP.cpp index 8131e1ca5..d0a76b22f 100644 --- a/DiscoPoP/DiscoPoP.cpp +++ b/DiscoPoP/DiscoPoP.cpp @@ -176,7 +176,11 @@ bool DiscoPoP::doInitialization(Module &M) { // DPInstrumentationOmission { - int bbDepCount = 0; + bbDepCount = 0; + + initializeBBDepCounter(); + + errs() << "Initial dep count: " << to_string(bbDepCount) << "\n"; ReportBB = M.getOrInsertFunction( "__dp_report_bb", @@ -233,6 +237,15 @@ bool DiscoPoP::doFinalization(Module &M) { } } } + // write the current count of BBs to a file to avoid duplicate BBids + outBBDepCounter = new std::ofstream(); + outBBDepCounter->open(".discopop/profiler/DP_BBDepCounter.txt", std::ios_base::out); + if (outBBDepCounter && outBBDepCounter->is_open()) { + *outBBDepCounter << bbDepCount; + outBBDepCounter->flush(); + outBBDepCounter->close(); + } + // DPInstrumentationOmission end return true; @@ -893,6 +906,15 @@ void DiscoPoP::initializeCUIDCounter() { } } +void DiscoPoP::initializeBBDepCounter(){ + std::string BBDepCounterFile = ".discopop/profiler/DP_BBDepCounter.txt"; + if (dputil::fexists(BBDepCounterFile)) { + std::fstream inBBDepCounter(BBDepCounterFile, std::ios_base::in);; + inBBDepCounter >> bbDepCount; + inBBDepCounter.close(); + } +} + bool DiscoPoP::isRecursive(Function &F, CallGraph &CG) { auto callNode = CG[&F]; for (unsigned i = 0; i < callNode->size(); i++) { @@ -2311,6 +2333,7 @@ bool DiscoPoP::runOnFunction(Function &F) { if (isa(pair.first->getTerminator())) { insertionPoint = insertionPoint->getPrevNonDebugInstruction(); } + errs() << "bbDepCount: " << bbDepCount << "\n"; auto CI = CallInst::Create( ReportBB, ConstantInt::get(Int32, bbDepCount), diff --git a/DiscoPoP/DiscoPoP.hpp b/DiscoPoP/DiscoPoP.hpp index 9f4241417..eb9a726e8 100644 --- a/DiscoPoP/DiscoPoP.hpp +++ b/DiscoPoP/DiscoPoP.hpp @@ -85,6 +85,7 @@ namespace { // CUGeneration static unsigned int CUIDCounter; + static unsigned int bbDepCount; static bool defaultIsGlobalVariableValue; int32_t fileID; @@ -217,6 +218,7 @@ namespace { ofstream *outCUs; ofstream *outOriginalVariables; ofstream *outCUIDCounter; + ofstream *outBBDepCounter; // Mohammad 23.12.2020 map loopStartLines; @@ -319,7 +321,6 @@ namespace { // DPInstrumentation end // DPInstrumentationOmission - int bbDepCount; string bbDepString; string fileName; int32_t fid; @@ -385,6 +386,7 @@ namespace { // Output function void initializeCUIDCounter(); + void initializeBBDepCounter(); string xmlEscape(string data); diff --git a/rtlib/iFunctions.cpp b/rtlib/iFunctions.cpp index 6b6822532..6f4f2b485 100755 --- a/rtlib/iFunctions.cpp +++ b/rtlib/iFunctions.cpp @@ -107,9 +107,6 @@ namespace __dp { /******* Helper functions *******/ void addDep(depType type, LID curr, LID depOn, char *var, string AAvar) { -#ifdef DP_RTLIB_VERBOSE - cout << "enter addDep\n"; -#endif // hybrid analysis if (depOn == 0 && type == WAW) type = INIT; @@ -210,9 +207,6 @@ namespace __dp { } cout << ", " << decodeLID(depOn) << "] into deps (" << myMap->size() << ")" << endl; } -#ifdef DP_RTLIB_VERBOSE - cout << "exit addDep\n"; -#endif } // hybrid analysis @@ -1061,17 +1055,13 @@ namespace __dp { return; } - void __dp_report_bb(int32_t bbIndex) { + void __dp_report_bb(uint32_t bbIndex) { #ifdef DP_PTHREAD_COMPATIBILITY_MODE std::lock_guard guard(pthread_compatibility_mutex); #endif #ifdef DP_RTLIB_VERBOSE cout << "enter __dp_report_bb\n"; cout << "bbIndex: " << std::to_string(bbIndex) << "\n"; - cout << "bbList: " << bbList << "\n"; - for(auto elem: *bbList){ - cout << "\t" << elem << "\n"; - } #endif bbList->insert(bbIndex); #ifdef DP_RTLIB_VERBOSE @@ -1079,7 +1069,7 @@ namespace __dp { #endif } - void __dp_report_bb_pair(int32_t semaphore, int32_t bbIndex) { + void __dp_report_bb_pair(int32_t semaphore, uint32_t bbIndex) { #ifdef DP_PTHREAD_COMPATIBILITY_MODE std::lock_guard guard(pthread_compatibility_mutex); #endif diff --git a/rtlib/iFunctions.hpp b/rtlib/iFunctions.hpp index d18851ae8..822c1f713 100644 --- a/rtlib/iFunctions.hpp +++ b/rtlib/iFunctions.hpp @@ -163,7 +163,7 @@ namespace __dp { BGNFuncList; // Hybrid analysis - typedef std::set ReportedBBSet; + typedef std::set ReportedBBSet; typedef std::set ReportedBBPairSet; // End HA // 2) when two END func are identical @@ -214,8 +214,8 @@ namespace __dp { // End HA #endif // hybrid analysis - void __dp_report_bb(int32_t bbIndex); - void __dp_report_bb_pair(int32_t counter, int32_t bbIndex); + void __dp_report_bb(uint32_t bbIndex); + void __dp_report_bb_pair(int32_t counter, uint32_t bbIndex); void __dp_add_bb_deps(char *depStringPtr); // End HA void __dp_finalize(LID lid); @@ -225,4 +225,4 @@ namespace __dp { void __dp_loop_entry(LID lid, int32_t loopID); void __dp_loop_exit(LID lid, int32_t loopID); } -} // namespace __dp +} // namespace __dp