diff --git a/src/mapleall/maple_me/include/me_pgo_instrument.h b/src/mapleall/maple_me/include/me_pgo_instrument.h index 77c8ac068010b829931adf001c146519b3e577aa..b1bc3d97864f5534b47e0d65ff494eaffd91a894 100644 --- a/src/mapleall/maple_me/include/me_pgo_instrument.h +++ b/src/mapleall/maple_me/include/me_pgo_instrument.h @@ -109,7 +109,7 @@ class PGOInstrument { bbs.push_back(dest); } else { if (func->GetMIRModule().IsCModule()) { - if (src->GetKind() == kBBIgoto) { + if (src->GetKind() == kBBIgoto || src->GetKind() == kBBGoto) { if (visitedBBs.find(dest) == visitedBBs.end()) { // In this case, we have to instrument it anyway bbs.push_back(dest); diff --git a/src/mapleall/maple_me/include/me_profile_use.h b/src/mapleall/maple_me/include/me_profile_use.h index 2014e800262fe15bdabf81ac2125a1cecdfe9589..e5d1de857cbf3e41a4354bd2a4a4bccc99a87c62 100644 --- a/src/mapleall/maple_me/include/me_profile_use.h +++ b/src/mapleall/maple_me/include/me_profile_use.h @@ -138,7 +138,7 @@ class MeProfUse : public PGOInstrument { return succCalcuAllEdgeFreq; } bool MapleProfRun(); - bool CheckSumFail(const uint64 hash, const uint32 expectedCheckSum, const std::string &tag); + void CheckSumFail(const uint64 hash, const uint32 expectedCheckSum, const std::string &tag); private: bool IsAllZero(Profile::BBInfo &result) const; void SetEdgeCount(BBUseEdge &edge, size_t value); diff --git a/src/mapleall/maple_me/src/me_profile_gen.cpp b/src/mapleall/maple_me/src/me_profile_gen.cpp index b29b27cd25b6e02d00e60709b3402506f881bc68..a36b769c429b4e4de3a64eef491dcdbf3c60d17d 100644 --- a/src/mapleall/maple_me/src/me_profile_gen.cpp +++ b/src/mapleall/maple_me/src/me_profile_gen.cpp @@ -187,7 +187,12 @@ bool MeProfGen::CanInstrument() const { } auto *bb = *bIt; if (bb->GetAttributes(kBBAttrIsTry) || bb->GetAttributes(kBBAttrWontExit)) { - return false; + if (func->GetMIRModule().IsCModule()) { + // Consider the case of non-exit as a special program + continue; + } else { + return false; + } } } return true; diff --git a/src/mapleall/maple_me/src/me_profile_use.cpp b/src/mapleall/maple_me/src/me_profile_use.cpp index 44538d4780dcfc551d5a8807c322c2446d6bc3ca..3e8f5e558ae56ccbeb17f6e37a56edf7fbd99d1a 100644 --- a/src/mapleall/maple_me/src/me_profile_use.cpp +++ b/src/mapleall/maple_me/src/me_profile_use.cpp @@ -305,16 +305,13 @@ FuncProfInfo *MeProfUse::GetFuncData() { return funcData; } -bool MeProfUse::CheckSumFail(const uint64 hash, const uint32 expectedCheckSum, const std::string &tag) { +void MeProfUse::CheckSumFail(const uint64 hash, const uint32 expectedCheckSum, const std::string &tag) { uint32 curCheckSum = static_cast((hash >> 32) ^ (hash & 0xffffffff)); if (curCheckSum != expectedCheckSum) { - if (dump) { - LogInfo::MapleLogger() << func->GetName() << " " << tag << " checksum doesn't match the expected " - << expectedCheckSum << " with " << tag << " real hash " << curCheckSum << '\n'; - } - return true; + LogInfo::MapleLogger() << func->GetName() << "() " << tag << " checksum " << curCheckSum + << " doesn't match the expected " << expectedCheckSum << "; aborting\n"; + abort(); } - return false; } bool MeProfUse::MapleProfRun() { @@ -323,16 +320,13 @@ bool MeProfUse::MapleProfRun() { return false; } func->GetMirFunc()->SetFuncProfData(funcData); - // early return if lineno fail - if (CheckSumFail(ComputeLinenoHash(), funcData->linenoChecksum, "lineno")) { - func->GetMirFunc()->SetFuncProfData(nullptr); // clear func profile data - return false; - } + // Abort if lineno fail + CheckSumFail(ComputeLinenoHash(), funcData->linenoChecksum, "lineno"); + FindInstrumentEdges(); - // early return if cfgchecksum fail - if (CheckSumFail(ComputeFuncHash(), funcData->cfgChecksum, "func")) { - return false; - } + // Abort if cfgchecksum fail + CheckSumFail(ComputeFuncHash(), funcData->cfgChecksum, "function"); + std::vector instrumentBBs; GetInstrumentBBs(instrumentBBs); if (dump) { diff --git a/src/mapleall/maple_phase/include/phases.def b/src/mapleall/maple_phase/include/phases.def index 0d6aaa1e44710c6cbdf62ca524b4dc48929a0cbc..5aa63aa504930684f9d90f9821cbc9358eda7673 100644 --- a/src/mapleall/maple_phase/include/phases.def +++ b/src/mapleall/maple_phase/include/phases.def @@ -11,7 +11,7 @@ ADDMODULEPHASE("callgraph", !Options::profileUse) ADDMODULEPHASE("inline", Options::O2 && Options::useInline && !Options::profileUse && !Options::enableInlineSummary) // run callgraph again to delete fully inlined static function ADDMODULEPHASE("callgraph", Options::O2 && Options::useInline && !Options::profileUse) -ADDMODULEPHASE("simplify", Options::O2 && !Options::genLMBC) +ADDMODULEPHASE("simplify", (Options::O2 && !Options::genLMBC) || (CLANG && Options::profileGen)) ADDMODULEPHASE("ConstantFold", Options::O2) // ipa phase manager ADDMODULEPHASE("IpaSccPM", CLANG && (Options::O2 || Options::profileGen || Options::profileUse))